Rites
Rites

Reputation: 2332

Unix command to create a tar of a specified number of files

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

Upvotes: 1

Views: 20276

Answers (6)

mmorrisson
mmorrisson

Reputation: 541

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.

Upvotes: 1

t0mm13b
t0mm13b

Reputation: 34592

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

Upvotes: 0

bmargulies
bmargulies

Reputation: 100133

tar cf path_of_tar.tar $(ls | head -10)

Add options to ls to select the 10 you want.

Upvotes: 10

Soufiane Hassou
Soufiane Hassou

Reputation: 17750

tar -cvf name.tar /path/to/file1 /path/to/file2 /path/to/file3 ...

Upvotes: 0

mipadi
mipadi

Reputation: 410952

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.)

Upvotes: 2

JB.
JB.

Reputation: 42134

The command you're looking for is: tar

How it's usually used:

$ tar cf file.tar file1 file2...

Upvotes: 3

Related Questions