is "cat" command limited to only 2 files ?
I have followed all threads I could find, and read the "info cat" per terminal. All examples give a command similar to: "cat file1 file2 > mergedfile".
What I need is a way to have many input files, not 2 only. When I try this command: "cat file1 file2 file3 file4 > mergedfile" the merged file contains only file1 and file2: file3 and file4 are not merged. What is the error? Can "cat" concatenate multiple input files? how to do? thanks! |
That should work - even "cat file[[:digit:]] > mergedfile" should do it. Which os/distro, and what version of cat "cat --version".
|
Nope. the limit is the buffer size available for parameters. It tops out around 10,000 to 20,000 file names, if they are relatively short.
What error message are you getting? |
No, you can concatenate any number of files into stdout.
Example (from "root" because I had the "lst" files handy): Code:
[root ~]# ls *lst |
Just once, try a new output file name with full path. I mean that accidentally you may be in an earlier sub-directory or reading an old version of the output.
Any ideas on how cat would work if files files3 or file4 were not text files? OK |
Cat couldn't care less.
|
Here's a script to concatenate files:
Code:
#!/bin/sh |
---------- Post added 04-06-14 at 11:24 PM ----------
[/COLOR]wow, many thanks for all the replies! I have followed the above, but still no luck. My distro is Ubuntu 13.10 I receive no error messages when I attempt to cat. The input files are MTS format. Here is what I am attempting..... 1) I copy all MTS files into "/working" 2) cd /working 3) cat 001.MTS 002.MTS 003.MTS 004.MTS > merged.MTS Always, the merged.MTS file contains the contents of the 001.MTS and 002.MTS files (which are properly concatenated). But, files 003 and 004 are simply ignored and not included in the cat process. I can find no explanation anywhere why cat would not merge all 4 files under one command. I can, though, cat 2 files in a series. Example: cat 001.MTS 002.MTS > merged01.MTS cat merged01.MTS 003.MTS > merged02.MTS cat merged02.MTS 004.MTS > merged03.MTS the above produces the desired result of an output file containing all 4 input files in proper cat order. but, this is an extremely cumbersome process. Aside, I can cat all 4 files by using "avconv", but avconv cannot preserve the MTS format (avconv must output to MP4) interesting? |
How are you determining that the files weren't copied?
I do this quite frequently without a problem (usually log files).[COLOR="Silver"] BTW, you can also use >> to append to the end of an existing file... |
what will type cat and which cat say?
Have you got any error message? |
Code:
for i in 001.MTS 002.MTS 003.MTS 004.MTS |
Quote:
OK |
Actually you can cat mpeg and mts without any problems. More complicated containers need conversion.
|
maybe they are actually avi's or something like that. people mis-label stuff all the time.
what does Code:
file * |
All times are GMT -5. The time now is 06:49 PM. |