tar command
LINUX-Frequently used commands
tar command Combine multiple files into one. |
Syntax |
tar [Option] [Archive location] [Archive source] |
The tar command is a command that combines multiple files into one. Putting several files together is called "archiving" How to execute the command. Specify the files to be archived as "Archive source".. Specify the name of the file to be archived in "Archive to". When run with the '-c' option, the tar command will archive the specified file. With the "x" or "t" option, the tar command will display the specified file information and extract the file from the archive. The tar command can be optionally specified without the hyphen '-'. |
Frequently used options |
c Create a new archive v Display execution results z Archive as zip t View archive contents x Extracting files from an archive f Output archive data to a specified file k When decompressing, if there is a file or directory with the same name, a warning is displayed and decompression is aborted.. |
Example: Create an archive. |
Archive the four files "temp_01.txt", "temp_02.txt", "temp_03.txt" and "temp_04.txt" as a "temp.tar" file $ tar cvf temp.tar temp* |
Example: Create an archive with gzip compression (archive extension tar.gz). |
$ tar czvf temp.tar.gz temp* |
Example: Create an archive with gzip compression (archive extension tgz). |
$ tar czvf temp.tgz temp* |