Running a command on many files

for file in xyz*
do
  ./transeq "$file" "${file}.faa" -table 11
done

This is a simple for loop that will iterate over every file that starts with xyz in the current directory and call the ./transeq program with the filename as the first argument, the filename followed by ".faa" as the second argument, followed by "-table 11".


If you install GNU Parallel you can do it in parallel like this:

parallel ./transeq {} {}.faa -table 11 ::: xyz*

If you program is CPU intensive it should speed up quite a bit.


You can do something like this on a bash command line:

printf '%s\n' {1..5025} | xargs -l -I {} -t ./transeq xyz{} xyz{}.faa -table 11

We are generating the integers from 1 to 5025 , one/line, then feeding them one-by-one to xargs, which encapsulates the integer into {} and then transplants it into the ./transeq command line in an appropriate manner.

Should you not have the brace-expansion facility {n..m} then you could invoke the seq utility to generate those numerics.

Or, you can always emulate the numeric generation via:

yes | sed -n =\;5025q | xargs ...