I\'m testing to do redirection with wildcards. Something like:
./TEST* < ./INPUT* > OUTPUT
Anyone have any recommendations? Thanks.
Say you have the following 5 files: TEST1
, TEST1
, INPUT1
, INPUT2
, and OUTPUT
. The command line
./TEST* < ./INPUT* > OUTPUT
will expand to
./TEST1 ./TEST2 < ./INPUT1 ./INPUT2 > OUTPUT.
In other words, you will run the command ./TEST1
with 2 arguments (./TEST2
, ./INPUT2
), with its input redirected from ./INPUT1
and its output redirected to OUTPUT
.
To address what you are probably trying to do, you can only specify a single file using input redirection. To send input to TEST
from both of the INPUT*
files, you would need to use something like the following, using process substitution:
./TEST1 < <(cat ./INPUT*) > OUTPUT
To run each of the programs that matches TEST*
on all the input files that match INPUT*
, use the following loop. It collects the output of all the commands and puts them into a single file OUTPUT
.
for test in ./TEST*; do
cat ./INPUT* | $test
done > OUTPUT