Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tar a set of files?

Tags:

People also ask

Can you tar multiple files?

If your system uses GNU tar , you can use tar in conjunction with the gzip file compression utility to combine multiple files into a compressed archive file. Note: In the above examples, the -z option tells tar to use gzip to compress the archive as it is created. The file extensions .

How do I tar multiple files in a folder?

To compress a single file by running tar -zcvf file. tar. gz /path/to/filename command on Linux. Tar and compress multiple directories file by running tar -zcvf file.


I am new to the tar command. I have many files in a directory: 1_1_1.txt, 1_1_2.txt, 2_1_1.txt, 2_1_2.txt..

I know there is a command:

tar cf file.tar *.txt 

which will tar all the four files into file.tar. ButI need to tar 1_1_1.txt and 1_1_2.txt into one tar file and 2_1_1.txt and 2_1_2.txt into another tar file. How can I accomplish this?