Find the answer to your Linux question:
Results 1 to 3 of 3
pardon me for asking this simple question, but how do we join multiple files? I have files like file1.dat, file2.dat, file3.dat........file1000.dat and i want to join all these files into ...
  1. #1
    Just Joined!
    Join Date
    Oct 2007
    Posts
    1

    joining multiple files

    pardon me for asking this simple question, but how do we join multiple files?
    I have files like file1.dat, file2.dat, file3.dat........file1000.dat and i want to join all these files into one file. How do i do it?
    please help
    thank you

  2. #2
    Just Joined!
    Join Date
    Aug 2007
    Posts
    37
    If your files had been named in alphabetical order (file0001.dat, file0002.dat, file0003.dat....file1000.dat) you could just use:
    Code:
    cat file*.dat >all_files.dat
    But, as your files are currently named, that will join them together in the wrong order.

    The solution is to do this:
    Code:
    for x in {1..1000}; do cat file${x}.dat >>all_files.dat; done

  3. #3
    Just Joined!
    Join Date
    Jan 2007
    Posts
    1

    Thank you

    Hi Jozyba,

    Thanks for your answer, I used it to join serveral AVI files.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...