Total Pageviews

Friday, April 13, 2012

tar file operations

Append files to tar :-->
[10:49pm agvarghe@sjc-ads-1011:20I]>tar -rvf pies.tar 2.pie 3.pie
2.pie
3.pie

[10:50pm agvarghe@sjc-ads-1011:20I]>

Task: List the contents of a tar file
Use the following command:
$ tar -tvf file.tar
Task: List the contents of a tar.gz file
Use the following command:
$ tar -ztvf file.tar.gz
Task: List the contents of a tar.bz2 file
Use the following command:
$ tar -jtvf file.tar.bz2

Extracting Specific Files
tar -xvf {tarball.tar} {path/to/file}

tar -C /myfolder -zxvf yourfile.tar to extract to another directory

The --delete option allows specified files to be completely removed from a tar file (except when the tar file is on magnetic tape). However, this is different from an extraction, as copies of the removed files are not made and placed in the current directory. Thus, for example, the files file1 and file2 can be removed from file.tar with the following:

    tar -f file.tar --delete file1 file2

No comments:

Post a Comment