I need to run a command on thousands of files in a directory. However, the program I'm using needs a parameters file on which the name of inputs and output are indicated. The command is as follows:
./program parameters_file.txt
These are the lines I need to edit on the parameters_file.txt, which are lines 1-3. The rest of the lines (not shown) remain the same:
input_file = asd123.OK
input_file2 = asd123.TXT
outfile = asd123.RESULTS_OUT
As seen, all files have matching names and only their extension changes.
I need to loop this so that input_file, input_file2 and outfile are overwritten every time the loop restarts. Something like: edit parameters_file.txt with 1st file name, run command on 1st file, edit parameters_file.txt with 2nd file name, run command on 2nd file, etc.
Thought about:
for f in *.OK;
do
input_file = $f
input_file2 = $f.TXT
outfile = $f.RESULTS_OUT
But I don't know how to incorporate it on the command and I can't write the loop in the parameters_file.txt because it will crash the program. Maybe echoing the parameters_file.txt or overwriting with sed?
Thanks.