If the names of your files is really in the form file1.ext1 file1.ext2 file2.ext1 file2.ext2
, then you can sort it with
echo *.{ext1,ext2}|sort -u
the above gives the output:
$ ll | grep ext
23880775 0 -rw-r--r-- 1 user users 0 Apr 29 13:28 file1.ext1
23880789 0 -rw-r--r-- 1 user users 0 Apr 29 13:28 file1.ext2
23880787 0 -rw-r--r-- 1 user users 0 Apr 29 13:28 file2.ext1
23880784 0 -rw-r--r-- 1 user users 0 Apr 29 13:28 file2.ext2
$ echo *.{ext1,ext2} | sort -u
file1.ext1 file2.ext1 file1.ext2 file2.ext2
Then you copy the output and call your program. But if you do in fact need the files with .ext1
before the files of .ext2
, then you have to either make sure that the .ext1
is alphabetically inferior to .ext2
or use another sorting criterion.
Optionally you could also adapt your executable to handle command line arguments in the correct order, but if you do already have an executable I'd recommend the first solution as work-around.
edit: this command does also sort lexically:
$echo *.ext[1,2]
$file1.ext1 file1.ext2 file2.ext1 file2.ext2