Since I often find myself searching for examples using tar I thought I’d compile some examples using the settings I most commonly use.
Create a new archive called archive.tar from the files contained in /some/directory.
tar -cvf archive.tar /some/directory
Create a new archive called archive.tar from all of the ruby (_.rb_) files in the current directory.
tar -cvf archive.tar *.rb
View the contents of an archive called archive.tar
tar -ft archive.tar
Add the file file.
tar -rvf archive.tar file.txt
Extract the archive into the current directory.
tar -xvf archive.tar
Extract the file; file.txt from the archive archive.tar
tar -xvf archive.tar file.txt
Written on 23 Dec 2009 and categorised in NIX, tagged as tar and examples