How to Cat multiple files with numeric differences
I think this is more a of a bash-terminology question than a cat question.
I have file.mkv.001 through file.mkv.160 How do I concatenate them into file.mkv without typing every individual entry? I think if I have file.mkv.a through file.mkv.z I can use "cat file.mkv.[a-z] > file.mkv" But that doesn't seem to work with the numeric extensions. Bash tells me "file.mkv.[001-160] not found". |
cat file.mkv.[01][0-9][0-9] >file.mkv
This will get all the files you listed. It would also get others if they existed (e.g. file.mkv.199) but so long as you only have the 001 through 160 extension you mention you should be OK. |
This will cat each file out in order into the file.mkv.full
Code:
for i in `ls -l file.mkv.[0-9][0-9][0-9] | awk '{print $8}' | sort -n`; do cat $i >> file.mkv.full; done |
Quote:
Also he didn't mention a requirement that the input be sorted in order. |
I did not mention that the files should be in order, but I thought the context would indicate that. "cat file.[a-z]" works in order, and .mkv is a video container file extension.
Thanks for your help, guys. What topic should I look up to understand how the square brackets work? The use we're discussing here is not the same as the left bracket command, is it? |
Regular Expresions (a/k/a regexp)
|
Code:
cat file.mkv.{001..160} |
Well thanks ya'll, the regular expression only method even returns the list in numeric order on my system.
|
All times are GMT -5. The time now is 04:37 AM. |