1

How can I collect several files into a single file?

I tried GZip, but could only get it to create separate files.

It does not have to be compressed.

Oliver Salzburg
  • 86,445
  • 63
  • 260
  • 306
rezx
  • 185
  • 1
  • 2
  • 9
  • I'm not entirely sure what you're asking, but the typical format for creating an archive (without compression) containing many files in Linux is [tar](http://en.wikipedia.org/wiki/Tar_%28file_format%29). It is then possible to compress the tar file. I believe commands such as gzip are supposed to work on single files and must be combined with tar for multiple files, e.g. .tar.gz would be a compressed (gzipped) tar. – Bob May 12 '12 at 11:59
  • thats what i want collect all files in one file how to do it by tar? – rezx May 12 '12 at 12:04
  • @rezx: "Use tar" is an answer to your posed question. To find out how it works, issue `man tar`. – Daniel Andersson May 12 '12 at 12:16
  • founded ' tar cvf output_filename.tar /path/to/dir1 ' ^_^ – rezx May 12 '12 at 12:17
  • u may vote to delete the post. – rezx May 12 '12 at 12:22

1 Answers1

5

Simply use cat:

cat file1 file2 file3 > output

If you want to combine all files in the current directory:

cat * > output

If you need to adjust the order of the files in the output, use echo first to get all filenames:

echo *

Then supply them in the desired order to cat.

Oliver Salzburg
  • 86,445
  • 63
  • 260
  • 306