Compress Example
This example will take all the files in the specified directory, compress them then write them into the single file specified. The command switches cvfz are, copy, verbose, files, and filter through gzip.
tar cvfz nameoffile.tar.z directoryname/
or
tar cvfz nameoffile.tar.gz directoryname/
or
tar cvfz nameoffile.tgz directoryname/
Decompress Example 1
This example will decompress the specified file, extracting all files and any directories into the current directory, leaving the compressed file unchanged. The command switches xvfz are extract, verbose, files, and filter through gzip.
tar xvfz nameoffile.tar.z
or
tar xvfz nameoffile.tar.gz
or
tar xvfz nameoffile.tgz
Decompress Example 2
This next example does exactly the same as the last one, with exception that it will work with versions of tar that do not support the z switch (if such a beast still exists). It works by first running gzip with the d and c command switches which will decompress the specified file and write the decompressed data to stdout. Its then piped into tar which extracts the files. The original compressed file is unchanged.
gzip -dc nameoffile.tar.z | tar -xvf -
or
gzip -dc nameoffile.tar.gz | tar -xvf-
or
gzip -dc nameoffile.tgz | tar -xvf -
Popularity: 1% [?]
