Tar Command Cheat Sheet
By Hideki Ishiguro at
tar
command archives files/directories, or extracts the archives.
In this article, I listed examples which we would use often.
For zip
and gzip
and bzip2
, please check the post.
Create archive from a file
tar -cf archive.tar sample.txt
If you want to display the result,
tar -cvf archive.tar sample.txt
Create archive from multiple files
tar -cf archive.tar sample1.txt sample2.txt
Append new files to the archive
tar -rf archive.tar sample.txt
Delete files from the archive
tar --delete -f archive.tar sample.txt
Extract archives
tar -xf archive.tar
If you want to display the result,
tar -xvf archive.tar
View the contents of the archive
tar -tf archive.tar