cat files in specific order based on number in filename
Use brace expansion
cat file.88_{0..100}.pdb >>bigfile.pdb
To ignoring printing the error messages for non-existent files use:
cat file.88_{0..100}.pdb >>bigfile.pdb 2>/dev/null
In the zsh
shell also you have the (n)
globbing qualifier to request a numerical sorting (as opposed to the default of alphabetical) for globs:
cat file.88_*.pdb(n) >>bigfile.pdb 2>/dev/null
cat $(for((i=0;i<101;i++)); do echo -n "file.88_${i}.pdb "; done)
or, regarding the comment of Jesse_b:
cat $(for((i=0;i<101;i++)); do test -f "file.88_${i}.pdb" && echo -n "file.88_${i}.pdb "; done)
In shell w/o brace expansion you can use ls
+ xargs
:
ls -v file.88_*.pdb | xargs cat > all.pdb
ls will sort files in numeric order:
-v
natural sort of (version) numbers within text.