Extract an archive to a directory different from the current, use the
-C or --directory, tar option, as in
tar -xf archive.tar -C /target/directory
Tar gzip compression$ tar cvzf archive_name.tar.gz dirname/
Tar bzipped compression
$ tar cvfj archive_name.tar.bz2 dirname/
Adding a file or directory to an existing archive using option -r
$ tar rvf archive_name.tar newdir/
Note: You cannot add file or directory to a compressed archive.
Estimate the tar archive size
The following command, estimates the tar file size ( in KB ) before you create the tar file.$ tar -cf - /directory/to/archive/ | wc -c 20480
Listing an archive using tar command
View the tar archive file content without extracting using option tvf
You can view the *.tar file content before extracting as shown below.$ tar tvf archive_name.tar
View the *.tar.gz file content without extracting using option tvzf
You can view the *.tar.gz file content before extracting as shown below.$ tar tvfz archive_name.tar.gz
No comments:
Post a Comment