Tag Archives: OS X

echo versus printf

Quick Note: When you’re bash scripting and you need to pipe some text into some process, you can use echo with the -n flag to suppress the echo‘s complimentary endline , or you can use printf, but using printf is more portable. Some machines implement echo differently and don’t support the -n flag. I found this advice and a longer explanation at this message board.

Working with hdiutil

This is more of a personal note regarding the hdiutil tool.

  • To create a sparse image:
$ hdiutil create NAME -volname NAME -type SPARSE -fs hfs+j
  • To mount the drive:
$ hdiutil attach NAME.sparseimage
  • To add data to the drive:
$ mv data.txt /Volumes/NAME
  • To unmount the drive:
$ hdiutil detach /Volumes/NAME

Then, if we delete the NAME.sparseimage file, it’s gone forever and ever.