-c : Creates Archive
-x : Extract the archive
-f : creates archive with given filename
-t : displays or lists files in archived file
-u : archives and adds to an existing archive file
-v : Displays Verbose Information
-A : Concatenates the archive files
-z : zip, tells tar command that creates tar file using gzip
-j : filter archive tar file using tbzip
-W : Verify a archive file
-r : update or add file or directory in already existed .tar file
Usage
Creating an uncompressed tar Archive using option -cvf
This command creates a tar file called file.tar which is the Archive of all .c files in current directory.
tar-cvf<file-name>.tar*.c
Output:
os2.c
os3.c
os4.c
Extracting files from Archive using option -xvf
This command extracts files from Archives.
tar-xvf<file-name>.tar
Output:
os2.cos3.cos4.c
gzip compression on the tar Archive, using option -z
This command creates a tar file called file.tar.gz which is the Archive of .c files.
tar-cvzf<file-name>.tar.gz*.c
Extracting a gzip tar Archive *.tar.gz using option -xvzf
This command extracts files from tar archived file.tar.gz files.
tar-xvzf<file-name>.tar.gz
Creating compressed tar archive file in Linux using option -j
This command compresses and creates archive file less than the size of the gzip. Both compress and decompress takes more time then gzip.
Untar multiple .tar, .tar.gz, .tar.tbz file in Linux
This command will extract or untar multiple files from the tar, tar.gz and tar.bz2 archive file. For example the above command will extract “fileA” “fileB” from the archive files.
Alternatively referred to as a ‘wild character’ or ‘wildcard character’, a wildcard is a symbol used to replace or represent one or more characters. Wildcards are typically either an asterisk (*), which represents one or more characters or question mark (?),which represents a single character.
To search for an image in .png format
This will extract only files with the extension .png from the archive file.tar. The –wildcards option tells tar to interpret wildcards in the name of the files to be extracted; the filename (.png) is enclosed in single-quotes to protect the wildcard () from being expanded incorrectly by the shell.