tags:

views:

202

answers:

6

I am looking for a Unix command which will create a tar of 10 files from a directory.

+4  A: 

The command you're looking for is: tar

How it's usually used:

$ tar cf file.tar file1 file2...
JB
+3  A: 

Well, depending on your needs...

$ tar cf tenfiles.tar file1 file2 file3 ... file10

That'll do it. You can check out the tar manpage ($ man tar) for further details on other options you might need. (Your question was a bit vague, so I can't be that much more specific.)

mipadi
A: 

Can you define what files are they? Are they of a specific filename pattern? My reasoning is asking that you specified 10 files.

In general:

tar cvf tar_with_10_files.tar somefile_with_wildcards_or_pattern_matching
tommieb75
A: 
tar -cvf name.tar /path/to/file1 /path/to/file2 /path/to/file3 ...
Soufiane Hassou
+5  A: 
tar cf path_of_tar.tar $(ls | head -10)

Add options to ls to select the 10 you want.

bmargulies
Thanks :-) ...Wish I could mark your answer useful...
Ritz
Just mark it 'accepted'. You asked the question, I think you can always do that.
bmargulies
A: 

I would suggest trying:

man tar

This will show all the options available and usage information. A typical usage for creating a tar of files in a directory would look like this:

tar -cvf myfiles.tar ./mydirectory

where myfiles.tar is the name of the tar file you want to create, and mydirectory is the directory the files reside in.

mmorrisson