UUENCODE(1) BSD Reference Manual UUENCODE(1)NAME
uuencode, uudecode - encode/decode a binary file
SYNOPSISuuencode [-m] [file] name
uudecode [-dm] [-o output] [file ...]
DESCRIPTION
Uuencode and uudecode are used to transmit binary files over transmission
mediums that do not support other than simple ASCII data.
Uuencode reads file (or by default the standard input) and writes an en-
coded version to the standard output. The encoding uses only printing
ASCII characters and includes the file permissions of the file and the
argument name for use by uudecode.
The following options are available:
-m Use MIME Base 64 encoding instead of the default encoding.
Uudecode reads encoded files (or by default, the standard input) and
writes an unencoded version to the file named name. This file will have
the mode of the original file except that no setuid or execute bits are
retained. The encoding format includes header and trailer lines. The
uudecode utility ignores lines preceding the header line or following the
trailer line. Lines preceding the header line must not, of course, look
like the header line.
The following options are available:
-d The input has no header or trailer lines, and is encoded in the
default format.
-m The input has no header or trailer lines, and is encoded in the
MIME Base64 format.
-o Put the output into the file named output instead of the file
name specified when the file was encoded.
Only a single file argument may be specified when the -d, -m or -o op-
tions are specified,
When using the default encoding format, the encoded form of the file is
expanded by 38% (each 45 bytes becomes 60 bytes, plus character count and
newline). control information). When using MIME Base64 encoding, the
encoded form of the file is expanded by 35% (eacah 56.25 bytes becomes 75
bytes, plus newline).
The uuencode and uudecode utilities exit 0 on success, and >0 if an error
occurs.
EXAMPLES
The following example packages up a source tree, compresses it, encodes
it and mails it to a user on another system. When uudecode is run on the
target system, the file ``src_tree.tar.gz'' will be created which may
then be uncompressed and extracted into the original tree.
tar cf - src_tree | gzip |\
uuencode src_tree.tar.gz | mail user@foo.bar.com
FORMAT
Files output by uuencode consist of a header line, followed by a number
of lines of encoded text, and a trailer line.
The header line is distinguished by having either ``begin '' or
``begin-base64 '' as its first word (note the trailing spaces). This
word is followed by a mode (in octal), one or more whitespace characters,
and a string which names the file. If the first character of the file
name is a tilde (``~''), the first slash-separated token of the pathname
is expanded to that user's home directory, similar to shell pathname ex-
pansions.
If the header line contains ``begin '', the body is encoded in the de-
fault format. If the header line contains ``begin-base64 '', the body is
encoded in the MIME Base64 format.
DEFAULT ENCODING
The lines of encoded text, in the default format, are at most 62 charac-
ters long (including the trailing newline). Each line consists of a
character count, followed by encoded characters, followed by a newline.
The character count is a single printing character. This character rep-
resents the number of bytes encoded in the rest of the line, and is that
number offset from the space character (octal 040). Such integers are
always in the range from 0 to 45 and can be determined by subtracting the
space character from the character.
Groups of 3 bytes are stored in 4 characters, 6 bits per character. All
except zero values are offset from the space character in the ASCII char-
acter set to make the characters printing. (Zero values are stored as
backquote (`) characters). The last line may be shorter than the normal
62 characters. If the size is not a multiple of 3, this fact can be de-
termined by the value of the count on the last line. Extra garbage will
be included to make the character count a multiple of 4.
The body is terminated by a line with a count of zero. This line histor-
ically consisted of one ASCII space (octal 040), but this was changed to
be a backquote (octal 140) to avoid problems with some mailers.
The trailer line consists of ``end'' on a line by itself.
MIME BASE64 ENCODING
The lines of encoded text, in the MIME Base64 encoding, are at most 76
characters long (including the trailing newline). Each line consists of
the encoded characters, followed by a newline.
Groups of 3 bytes are stored in 4 characters, 6 bits per character. Each
group of 6 bits is converted to a printable character based on the con-
version table specified by the MIME Base64 standard encoding. The last
line may be shorter than the normal 76 characters. If the size is not a
multiple of 3, 0 bits are added to form an integral number of 6 bit
groups. Output character positions that are not required to represent
input data are written as equal signs (``='').
The body is terminated by a trailer line, which consists of ``===='' on a
line by itself.
SEE ALSOgzip(1), mail(1)
Internet MIME RFC 1341.
HISTORY
The uuencode and uudecode commands appeared in 4.0BSD.
4th Berkeley Distribution June 6, 1993 2