I have a Bash script where i have calculated many values and stored them in the variables which have a number for each row. For instance, i have a variable named as TC_5
which calculates the value of 5th row of the input csv file. I have calculated all the values and stored in variables which have the naming convention of TC_<Row_No>
so that for 200 rows i have values stored in:
TC_1
TC_2
.
.
TC_200
Now, i want to write a loop which could print the values of all these variables together to an external file instead of manually printing them. For this, i am using the while loop as follows:
i=0
while [ "$i" != 201 ]
do
echo "TC_$i" >> Out
i=`expr $i + 1`
done
How can i modify the above code in such a way that the echo statement would print the variable TC_<RowNo>
to the Out
File?
awk/sed
? – MatthewRock Sep 22 '15 at 08:03