27.08.2015 Views

Advanced Bash−Scripting Guide

Advanced Bash-Scripting Guide - Nicku.org

Advanced Bash-Scripting Guide - Nicku.org

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Advanced</strong> <strong>Bash−Scripting</strong> <strong>Guide</strong><br />

gzip<br />

The standard GNU/UNIX compression utility, replacing the inferior and proprietary compress. The<br />

corresponding decompression command is gunzip, which is the equivalent of gzip −d.<br />

The zcat filter decompresses a gzipped file to stdout, as possible input to a pipe or redirection. This<br />

is, in effect, a cat command that works on compressed files (including files processed with the older<br />

compress utility). The zcat command is equivalent to gzip −dc.<br />

On some commercial UNIX systems, zcat is a synonym for uncompress −c, and will<br />

not work on gzipped files.<br />

bzip2<br />

See also Example 7−7.<br />

An alternate compression utility, usually more efficient (but slower) than gzip, especially on large<br />

files. The corresponding decompression command is bunzip2.<br />

Newer versions of tar have been patched with bzip2 support.<br />

compress, uncompress<br />

This is an older, proprietary compression utility found in commercial UNIX distributions. The more<br />

efficient gzip has largely replaced it. Linux distributions generally include a compress workalike for<br />

compatibility, although gunzip can unarchive files treated with compress.<br />

sq<br />

The znew command transforms compressed files into gzipped ones.<br />

Yet another compression utility, a filter that works only on sorted ASCII word lists. It uses the<br />

standard invocation syntax for a filter, sq < input−file > output−file. Fast, but not nearly as efficient<br />

as gzip. The corresponding uncompression filter is unsq, invoked like sq.<br />

The output of sq may be piped to gzip for further compression.<br />

zip, unzip<br />

Cross−platform file archiving and compression utility compatible with DOS pkzip.exe. "Zipped"<br />

archives seem to be a more acceptable medium of exchange on the Internet than "tarballs".<br />

unarc, unarj, unrar<br />

These Linux utilities permit unpacking archives compressed with the DOS arc.exe, arj.exe, and<br />

rar.exe programs.<br />

File Information<br />

file<br />

A utility for identifying file types. The command file file−name will return a file specification<br />

for file−name, such as ascii text or data. It references the magic numbers found in<br />

/usr/share/magic, /etc/magic, or /usr/lib/magic, depending on the Linux/UNIX<br />

distribution.<br />

The −f option causes file to run in batch mode, to read from a designated file a list of filenames to<br />

analyze. The −z option, when used on a compressed target file, forces an attempt to analyze the<br />

uncompressed file type.<br />

bash$ file test.tar.gz<br />

Chapter 12. External Filters, Programs and Commands 179

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!