user7169125 user7169125 - 4 months ago 24
Bash Question

Script to run C++ code with different user input

I have a c++ executable file 'Score' that takes as input two user defined 'values'.
These values are some data in txt files. I run the program and save the output to a text file like this :

./Score data1.txt data2.txt >outdata1data2.txt

Because I need to run this for many times would be possible to create a shell bash script that does this automatically something like :

./Score data1.txt data3.txt >outdata1data3.txt
./Score data1.txt data4.txt >outdata1data4.txt

and so on..

The names of the data are all different and all in the same directory as the executable file.
My knowledge in C++ is very limited and any help would be appreciated


It is definitely possible. You will probably want to write a shell script similar to this:

for filename1 in /*.txt; do
  for filename2 in /*.txt; do
    ./Score "$filename1" "$filename1" > "out$filename1$filename2"