Tar Command – How to Tar Multiple Files in a Directory (Linux/Unix)

filestar

Is there a fairly simple way to tar several (specific) files in a directory? For example let's say the following is a directory:

-rw-r--r-- 1 allend bin     98 Jul 20 15:50 scriptlog.log
-rw-r--r-- 1 allend bin  19533 Jul 29 21:47 serveralert.log
-rwxr--r-- 1 allend bin   1625 Jul 29 21:47 orion
-rw-r--r-- 1 allend bin  24064 Jul 29 21:49 orion_files.tar
-rwxr--r-- 1 allend bin    156 Aug  4 21:22 htmltest
-rw-r--r-- 1 allend bin    131 Aug  4 21:23 page.html

What if I only want to tar the files serveralert.log and page.html?

Best Answer

Is there something wrong with listing the files you'd like to add to the .tar file?

$ tar cvf some.tar file1 file2 file3

Example

$ tar cvf some.tar serveralert.log page.html
serveralert.log
page.html
Related Question