How to print variable inside awk
awk, bash, scripting
Solution
I think this is what you want:
#!/bin/bash
file=tau
f=2.54
order=even
awk "{sum+=\$2}; END {print \"${file}_${f}_${order}_v1.xls\", sum/NR}" \
${file}_${f}_${order}_v1.xls >> safe/P-state-summary.xls
Problem
I want the awk to interpret the variable as follows ``` #!/bin/bash file=tau f=2.54 order=even awk '{sum+=$2}; END {print '${file}_${f}_${order}_v1.xls', sum/NR}' ${file}_${f}_${order}_v1.xls >> safe/P-state-summary.xls ``` I want the desired output as follows - ``` tau_2.54_even_v1.xls sum/NR ``` Can anybody help me out with this ?