Creating archives
To create a tar
archive the c
switch is used. To further encode it using gzip
compression the j
option is also added, or for bzip2
compression the j
switch is included. Note that tar
program pipes its output into gzip
and bzip2
tools in order to create the tar.gz
and tar.bz2
archives, respectively. OK, to compress a directory called dir
into dir.tar
, dir.tar.gz
and dir.tar.bz2
archives, the following commands are used, respectively.
tar cf dir.tar dir/
tar czf dir.tar.gz dir/
tar cjf dir.tar.bz2 dir/
Extracting archives
Extracting archives is also very simple. Instead of the c
switch the x
is used and the archive name is given as the only other parameter. The commands for archive extraction shown below correspond to the archive creation commands given earlier.
tar xzf dir.tar.gz
tar xjf dir.tar.bz2
The verbose mode
The v
switch can be used to enable the verbose mode. This can be useful if you would like to see a list of files being compressed or extracted. For example, lets extract the dir.tar.gz
archive, with verbose mode enabled, using the following command.
The above command produces a list of inflated files as shown in the following output.
dir/dir/NVIDIA_DRIVER_README.txt
dir/NVIDIA_LICENSE.txt
dir/readme.txt
No comments:
Post a Comment