HFS Utilities

February 1st, 2000 by Marjorie Richardson in

Data on Macintosh disks can be read into Linux quite easily with this tool package.
Your rating: None

Macintosh users may be a minority, but they are quite loyal to their operating system and loathe to give it up. Mac OS stores its files in HFS (hierarchical file system) format, which uses a return character to separate lines in text files, rather than a newline character as in Linux/UNIX. If you have files on a Macintosh floppy disk that you wish to get on your Linux system, several options are available.

Just as “m” commands deal with DOS disks, “h” commands work for Macintosh disks. These commands are named and behave just as any Linux user might expect. For example, to change directories on your Linux system, you type cd path; to do so with a Mac volume, you type hcd path. In other words, you just add an “h” as the first character of the command name. In some cases, the base command name is taken from DOS rather than UNIX—I guess to make the h tools consistent with the m tools. The most frequently used h utilities are:

  • hcd path: change working directory on the disk; default is the root (/) directory

  • hdel names: delete a file or files on the disk

  • hcopy source destination: copy a file to or from an HFS disk

  • hdir: list the files on the disk; hls also works for this purpose

  • hmkdir path: create a directory on the disk; hrmdir removes a directory on the disk

  • hmount device_name: mount the HFS disk at this location; humount unmounts the disk

Other available commands are hformat, hpwd, hrename, hvol and hatrib. For details on these HFS utilities and their options, see the man pages.

Wild cards are permitted in specifying path names, but be aware that if you use “*” to mean “every file in the directory”, it will not be interpreted that way. For example, typing hcopy * . will look for the filenames on the HFS floppy in the current directory , instead of getting all the files off the HFS floppy as you would expect.

Another method for manipulating Mac disks is the hfs shell. This shell, based on Tcl, provides the same type of options as the h commands: mount (m), umount (u), cd (c), dir (d), mkdir (m), rmdir (r), etc. The difference is only in the way the command is specified. For example, to mount the disk with hfs, you type:

hfs m

instead of

hmount
Finally, Robert Leslie's program xhfs provides a graphical user interface to the hfs commands. It is easy to use and quite intuitive. Just type:
xhfs
and up pops a window displaying available options (see Figure 1). A click of the mouse on the button next to the option you want, and you are on your way to having those files on your system in Linux format.

If a friend sends you a Macintosh file, don't forget you need to get rid of those pesky return characters. The tr command (see “A Little Devil Called tr” by Hans de Vreught, LJ, September 1998) is the best tool for doing this. Typing

tr '\015' '\012' <

will do the trick.

Another good resource for these commands and others is Linux for Dummies Quick Reference, 2nd Edition by Phil Hughes.

Marjorie Richardson is Editor in Chief of Linux Journal. A movie aficionado, she is currently enamored of DVD technology and can't bear to watch movies “that have been formatted for your TV screen”.

__________________________


Special Magazine Offer -- 2 Free Trial Issues!
Receive 2 free trial issues of Linux Journal as well as instant online access to current and past issues. There's NO RISK and NO OBLIGATION to buy. CLICK HERE for offer

Linux Journal: delivering readers the advice and inspiration they need to get the most out of their Linux systems since 1994.

Sorry, offer available in the US only. International orders, click here.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
enigma free mp3 download's picture

linux

On October 2nd, 2007 enigma free mp3 download (not verified) says:

my kernel report of messages? Why error" lots does "APIC . Bye.

Post new comment

Please note that comments may not appear immediately, so there is no need to repost your comment.
The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <pre> <ul> <ol> <li> <dl> <dt> <dd> <i> <b>
  • Lines and paragraphs break automatically.

More information about formatting options

Featured Videos

The November 13, 2008 edition of Linux Journal Live! Shawn Powers and special guest, Linux Journal Author Daniel Bartholomew, talk e-book readers and Daniel's Kindle, DRM, and other goodness.

From the Magazine

December 2008, #176

The Oxford English Dictionary says the word "gadget" is a placeholder name for a technical item whose precise name one can't remember. Like that book-reader thingy from Amazon...what's it called? Spindle, Gindle...Kindle, that's it. Check it out in this month's gadget issue.

Other gadgets covered include the Nokia tablets, the BlackBerry, the Neo FreeRunner, the Dash Express, the Roku Netflix Player, the Kangaroo TV, The TomTom GO 930 and the MooBella Ice Cream System. On the larger hardware front, read the reviews of the Acer Aspire One and the YDL PowerStation. On the software front, check out the articles and columns on memcached, Samba security, Mutt, desktop gadgets, bash and Puppet. To wrap it all up, read Doc's thoughts on Google and the browser platform.

Read this issue

Sign up for our Email Newsletter