ARCHIVED: What is a uuencoded mail message or news posting, and how can I decode it?

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.

uuencode is a program that encodes binary files as plain ASCII text so that they can be sent through electronic mail or posted to Usenet newsgroups. The program expands single characters that can't be viewed or printed as normal text into pairs of text characters, and the resulting encoded file is somewhat larger than the original binary file. This process is necessary to prevent mail, news, and terminal programs from misinterpreting the non-text characters in binary files as special instructions.

You can recognize a uuencoded file by its format. There should be a "begin" line, followed by many lines of identical length filled with what looks like gibberish, generally beginning with the letter M. Here's an example:

  begin 644 myfile.zip
  M4$L#!`H``````*I.)1\]0KO)J5(6`*E2%@`,````1%)5241$,#0N6DE04$L#
  M!`H``````)9C#Q_E,1QY)3D6`"4Y%@`,````1%)5241$14TN03`S8.HL`!X&
  M`0`4``*1D6,5'Y%C%1\``````````````````$1254E$1$5-+D$P,P``<`V[

These lines should eventually terminate with an "end" line near the end of the file. If this is not the case, you may have a garbled file or a single file from a multi-part message.

Decoding in Unix

If you receive a uuencoded file as a Unix mail message, to decode it:

  1. Copy it to a file (c o in Berkeley Mail).
  2. Edit the file, removing the mail header, any signatures, and any other extraneous information in the text before the "begin" line and after the "end" line.
  3. After you have a clean uuencoded file (e.g., filename.uu), enter:
      uudecode filename.uu
    Replace filename.uu with the name of your file. This will reconstruct the file that was originally encoded.
  4. After running the uudecode command, you will have two files: the original unchanged uuencoded file, and the new decoded file. The decoded file will have the name that was specified at the beginning of the uuencoded file.

If you receive an error message such as "Short file", you may have a corrupted or incomplete uuencoded file. Check to be sure that there is a line that says "end" at the end of the file. You can look at the last few lines of a file named filename.uu by entering:

  tail filename.uu

If there is no "end" line, you are probably missing the remainder of the uuencoded file. If you are trying to decode a file stored in several parts, such as a set of Usenet postings, make sure you have properly stripped off all header and signature information from the pieces and properly concatenated them together. For example, to append filename2.uu, the second part of a two-piece file that contains the "end" line, to the first part, filename1.uu, you would enter:

  cat filename2.uu >> filename1.uu

In this case, you should strip the footer from filename1.uu and the header from filename2.uu, so that all the lines beginning with "M" follow each other without interruption.

Note: Some newsreaders, such as trn, have special commands for easily decoding multi-part posted files.

For more information, at the Unix shell prompt enter:

  man uudecode

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

This is document acup in the Knowledge Base.
Last modified on 2018-01-18 09:19:57.