I am trying to extract data from a trace files and calculate the sum. For a single file, the following command works :
cat avg.txt| gawk '{T+=$1} END {print T "\n"}'
But when I try using it with xargs command, as I have to do the same operation on multiple fils,I get a syntax error.
ls *avg* | xargs -i sh -c " cat {} | gawk '{T+=$1} END {print T "\n"}'"
gawk: {T+=} END {print T n}
gawk: ^ syntax error
Can someone tell me what is the problem?