5

Glob with Numerical Order

view full story
linux-howto

http://unix.stackexchange.com – I have this list of pdf files in a directory: c0.pdf c12.pdf c15.pdf c18.pdf c20.pdf c4.pdf c7.pdf c10.pdf c13.pdf c16.pdf c19.pdf c2.pdf c5.pdf c8.pdf c11.pdf c14.pdf c17.pdf c1.pdf c3.pdf c6.pdf c9.pdf I want to concatenate these using ghostscript in numerical order (similar to this): gs -q -sPAPERSIZE=a4 -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=out.pdf *.pdf But the shell expansion order does not reproduce the natural order of the numbers but the alphabetical order: $ for f in *.pdf; do echo $f; done c0.pdf c10.pdf c11.pdf c12.pdf c13.pdf c14.pdf c15.pdf (HowTos)