Note : A ".tar" file is not a compressed files, it is just a collection of files within a single file. If the file is a ".tar.gz" or ".tgz" then its a collection of many files in a single file which is compressed. The file ".tgz" or ".tar.gz" represents a tarball file.
Creating a tar file :
Code:
tar -cvzf file1.tar file2.txt
c : to create archive
v : verbose mode output
z : compress file
f : specify file or file group
You can use wild card characters to tar a group of files by *.[file extension]
Example :
Code:
tar -cvzf file1.tar *.txt *.doc
The above command will create (c) verbose mode (v) tar archive and compress (z) files specified (f) in the command. All the .txt and .doc files will be archived.
Extracting the files from a tar file :
To extract an uncompressed tar file :
Code:
tar -xvvf file1.tar
This will Extract the files in tar files in the current location.
To extract a compressed tarball file :
Code:
tar -xvvzf myfile.tar.gz
Bookmarks