ARCHIVED: In Unix, how do I use the MacUtils to encode or decode a document in MacBinary or BinHex?

This content has been archived, and is no longer maintained by Indiana University. Information here may no longer be accurate, and links may no longer be available or reliable.

Using the MacUtils, a suite of freeware utilities, allows you to create and decode MacBinary and BinHex files from the Unix command line prompt.

To decode a BinHexed file, enter at the Unix prompt:

  hexbin [options] file.hqx

Replace file.hqx with the file you wish to decode and [options] with one or more of the following options:

-3
Decode the BinHex file. Put the data fork in a file with the extension .data, the resource fork in a file with the extension .rsrc, and Finder information in a file with the extension .info. With the exception of the file extension, the names of all three files will be identical (e.g., file.data, file.rsrc, and file.info).
-f
Identical in behavior to -3, except that it will not create empty fork files. So, if a file doesn't have a resource fork, hexbin will not create a .rsrc file.
-r
With this option selected, hexbin will only decode resource forks. Thus, if a file has a data fork, the program will ignore it.
-d
With this option selected, hexbin will only decode data forks. Thus, if a file has a resource fork, the program will ignore it.
-u or -U
With this option selected, hexbin will decode only the data fork of a file and will exchange all carriage return characters with line feeds. This option should only be used with text files. Using the -u option creates a file with the extension .text while using the -U option creates a file with no extension.
-b
This option tells hexbin to convert the file into MacBinary format, saving it into a file with the .bin extension. This is the default, so if you don't specify any options, this is the action hexbin performs.
-s
Identical to -b, except that instead of saving the MacBinary output to a file, it sends it to standard output. This option is best used in conjunction with a pipe.
-l or -v
Lists files that are being extracted. The two options are similar, except that -v gives more information.
-i
Works the same as -l, except no extraction is actually performed.
-n [name]
Replace [name] with the name you wish to give the decoded file.

To decode a MacBinary file, enter at the Unix prompt:

  macunpack [options] file.bin

Replace file.bin with the file you wish to decode. The options for macunpack are identical to those for hexbin.

To create a BinHex file, enter at the Unix prompt:

  binhex [options] file > file.hqx

Replace file and file.hqx with, respectively, the file you wish to encode and the name you wish to give the resulting BinHexed file. This command has the following options:

-r
With this option selected, binhex encodes file as a resource fork.
-d
With this option selected, binhex encodes file as a data fork.
-u or -U
This option is similar to -d except it should only be used to encode text files. It exchanges line feeds for carriage returns.
-c [creator]
Replace [creator] with the file creator code you wish to assign to the document. If you do not specify a file creator, the resulting BinHexed file's creator will be MACA with the -d and -u options and RSED with the -r option.
-t [type]
Replace [type] with the file type code you wish to assign to the document. If you do not specify a file type, the resulting BinHexed file's type will be TEXT with the -d and -u options and RSRC with the -r option.
-l
Writes information about the file being encoded
-i
Works like -l, except no actual encoding is performed

If you wish to encode the forks of a previously decoded file back into a BinHexed Mac OS file, replace file in the example above with the Finder information file (the file with the .info extension). You do not use the -r, -d, or -u options when you do this.

Creating a MacBinary file is a very similar process. The only difference is that you pipe the output of the binhex command into hexbin rather than redirecting it to a file. So, at the Unix prompt, enter:

  binhex [options] file | hexbin

This will create a MacBinary file with the same name as file except it will have a .bin extension.

At Indiana University, for personal or departmental Linux or Unix systems support, see Get help for Linux or Unix at IU.

This is document aewr in the Knowledge Base.
Last modified on 2018-01-18 12:20:51.