GNU/Linux Command – TAR

tar — Create/Add/Extract Tape ARchives files.
 
Summary:
tar is an archiving program designed to store and extract files from an archive file known as a tar file. In olden days, tar file may be made on a tape drive. But in recent days, it is very common to write a tar file to a normal file.
 
Normally “.tar” file is a collection of files within a single file in uncompress mode. And “.tar.gz”/ “.tgz” file is a collection of files in compressed mode.
 
Example:

$ tar -cf myfile.tar file1 file2 -- Create a tar file. $ tar -cf myfile.tar mydir -- Create a tar file.  $ tar -cvf myfile.tar mydir -- With detail output. $ tar --exclude="*.doc" -cvf myfile.tar mydir -- Exclude doc files. $ tar --exclude="*.doc" --exclude="*.xls" -cvf myfile.tar mydir-- Exclude doc and xls files. $ tar -tvf myfile.tar -- List the content of the tar file.  $ tar -uvf myfile.tar mydir -- Update/Append files that are newer than copy in tar. $ tar -xvf myfile.tar -- Extract the tar file. $ tar -xvf myfile.tar dir/file1 -- Extract only file1 from the tar. $ tar --delete -vf myfile.tar *.doc -- Delete all files with .doc extn from the tar file.  $ tar --diff -vf myfile.tar mydir -- Diff between the archive and mydir. $ tar -czvf myfile.tgz mydir -- Tar and GZip the files. $ tar -xzvf myfile.tgz -- Extract the tgz file.  $ tar -cZvf myfile.tgz mydir -- Tar and compress the files. $ tar -xZvf myfile.tgz -- Extract the tgz file.
Read: man tar

 

Advertisements
Tagged with: ,
Posted in Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: