3 Unix / Linux uuencode Command Examples (Encode Binary File)

uuencode command is used to encode a binary file as explained in the examples below.

1. Basic uuencode Example

By default, uuencode takes input from the standard input, and writes it to the standard output as shown below.

# uuencode /dev/stdout
testing this is line 1
testing this is line 2
[press Ctrl-D here]

After typing the above two lines, press Ctrl-D, which will display the encoded output. Please note that just for explaining we are giving clear ASCII text in the above example.

# uuencode /dev/stdout
begin 644 /dev/stdout
testing line 1
testing line 2
[press Ctrl-D here]

2. Encode a Binary file to ASCII text

The following example encodes the test.tar.gz (tar compressed file) binary file, and displays the encoded ASCII data on the standard output.

# uuencode test.tar.gz /dev/stdout
begin 644 /dev/stdout

3. Encode a Binary file to ASCII text in BASE-64

By default uuencode command uses the standard UU encoding format. Use the option -m to encode in base-64 as shown below.

# uuencode -m test.tar.gz /dev/stdout
begin-base64 644 /dev/stdout

Please note that to decode this ASCII text back to corresponding binary file, you need to use uudecode command.

Comments on this entry are closed.