UPDATED:
I have this awk command I want to nest into a system("") command.
awk ' BEGIN {yr=2016} !/^#/ && NF!=0 { for(i=2;i<=NF;i++) a[i]+=$i } END { for (y=2;y<=NF;y++) print yr++ " - (" a[y] " Loads)" }' vol.dat
so I tried this:
system("awk ' BEGIN {yr=2016} !/^#/ && NF!=0 { for(i=2;i<=NF;i++) a[i]+=$i } END { for (y=2;y<=NF;y++) print yr++ \" - (\" a[y] \" Loads)\" }' vol.dat")
Bash does not like it due to the nesting and I am obviously not escaping the quotes correctly. However I try to escape the characters I can not get it to print with a space.
Here is some sample input, but as I said it is not an awk problem it is an issue with the awk command being nested in double quotes and escape characters:
vol.dat
Jan 0 165 165 228 78
Feb 10 52 149 196 79
Mar 46 186 159 137 182
Output:
2016 (56 Loads)
2017 (403 Loads)
2018 (473 Loads)
2019 (561 Loads)
2020 (339 Loads)

vol.datsh -c "..."instead of from gnuplot'ssystem("...")since relatively few people will have the latter to test with and the same concerns almost certainly apply to both.Outputthe output you get or the output you want? Please make sure to show us the output you want.