I'm trying to find average of values in 2nd column in some files. Filenames have following pattern eg:
tau_2.54_even_v1.xls
tau_2.54_odd_v1.xls
tau_1.60_v1.xls
tau_800_v1.xls
The other filenames can be obtained by replacing variable file with oter variables pmb , xhpl etc .. Here is the script I've written .. Can anyone kindly find the error and let me know ?
#!/bin/bash
for file in pmb_mpi tau xhpl mpi_tile_io fftw ; do
for f in "2.54" "1.60" "800" ;do
if [ ${f} = 2.54 ]
then
for order in even odd ; do
echo ${file}_${f}_${order}_v1.xls
awk 'sum+=$2 ;END {print "Average = " , $sum/NR > ${file}_${f}_${order}_avrg.xls }' ${file}_${f}_${order}_v1.xls
done
else
echo ${file}_${f}_v1.xls
awk 'sum+=$2 ;END {print "Average = " , $sum/NR > ${file}_${f}_avrg.xls }' ${file}_{f}_v1.xls
fi
done
done