As we've shown you in this chapter, you use separate commands to encode/unencode, tar/untar, compress/uncompress, and zip/unzip files and directories. A lot of times, however, you can pipe commands together and run them in sequence, saving you time and hassle. For example, as Code Listing 13.14 shows, you can uudecode and gunzip files at the same time by piping the commands together. You can also uncompress and untar at one time, and you can tar and gzip at one time.
To uudecode and gunzip at one time:
1. | ls -l Use ls -l to verify the existence of your uuencoded and zipped file. |
2. | uudecode -o /dev/stdout home. gz.uue | gunzip > home Here, we use -o /dev/stdout to send the uudecode output to the standard output, then pipe the output of the uudecode command to gunzip, then redirect the output of gunzip to the home file. Whew! See Code Listing 13.14 for the details. |
[ejr@hobbes compression]$ ls -l h* -rw-rw-r-- 1 ejr users 73978 Jul 23 11:15 home.gz.uue -rw-r--r-- 1 ejr users 177607 Jul 27 09:34 house.uue [ejr@hobbes compression]$ uudecode -o /dev/stdout home.gz.uue | gunzip > home [ejr@hobbes compression]$ ls -l h* -rw-r--r-- 1 ejr users 128886 Jul 27 10:48 home -rw-rw-r-- 1 ejr users 73978 Jul 23 11:15 home.gz.uue -rw-r--r-- 1 ejr users 177607 Jul 27 09:34 house.uue [ejr@hobbes compression]$ |
To uncompress and untar at one time:
uncompress filename.tar.Z | tar xf -
[ejr@hobbes compression]$ ls -l *.Z -rw-r--r-- 1 ejr users 297027 Jul 27 10:06 labrea.tar.Z [ejr@hobbes compression]$ uncompress labrea.tar.Z | tar -xf - [ejr@hobbes compression]$ ls -l l* -rw-r--r-- 1 ejr users 5011760 Jul 27 10:06 labrea.tar [ejr@hobbes compression]$ ls -ld L* drwxr-xr-x 2 ejr users 1024 Jul 27 10:16 Labrea [ejr@hobbes compression]$ |
To tar and gzip at one time:
tar cf - Labrea | gzip > labrea.tar.gz
[ejr@hobbes compression]$ ls -ld F* drwxrwxr-x 2 ejr users 1024 Jul 23 10:56 Feather [ejr@hobbes compression]$ tar -cf - Feather | gzip > feather.tar.gz [ejr@hobbes compression]$ ls -l f* -rw-r--r-- 1 ejr users 106752 Jul 27 10:54 feather.tar.gz -rw-rw-r-- 1 ejr users 128886 Jul 23 11:45 file1.htm -rw-rw-r-- 1 ejr users 128886 Jul 23 11:45 file2.htm -rw-rw-r-- 1 ejr users 686080 Jul 23 10:41 folder.tar -rw-rw-r-- 1 ejr users 268156 Jul 23 06:53 folderzip.zip -rw-rw-r-- 1 ejr users 128886 Jul 23 06:37 fortunes1.txt -rw-rw-r-- 1 ejr users 55124 Jul 23 06:38 fortunes1.zip [ejr@hobbes compression]$ |
18.188.218.157