Reputation: 193
I'm trying to write a script that goes through 5 script files and executes them using the contents of t1-5 as inputs and appends the outputs to a log file but it doesn't seem to be working. I'm trying to increment a variable i representing the number of the t variables. Am I doing that right? And is this output redirection making sure that all the results are appended to the same file?
t1=`cat t1`
t2=`cat t2`
t3=`cat t3`
t4=`cat t4`
t5=`cat t5`
cd ..
cd tmp
i=1
for g in `ls`
do
sh "$g" "t$i" > 0572log
i=$((i + 1)
done
Upvotes: 0
Views: 34
Reputation: 4841
First, i=$((i + 1)
should be i=$((i + 1))
.
Second, > 0572log
should be >> 0572log
in order to append and not overwrite.
Third, if you expect to run the script more than once it would be best to put 0572log
somewhere else (e.g. ../0572log
), and not in your tmp
directory. Otherwise, the next time you run the script it will try to execute 0572log
.
The quotes around $g
and t$i
are not required if you have simple file names without whitespace.
Upvotes: 1