I am trying to use an awk command within a ksh script but it is not working - I am able to run from command line with no problem. It does not err out - it just does not produce a file with final count.
awk "{s+=$0} END {print s}" es.out > es.cnt
Any help would be greatly appreciated. Thanks
Yoda
January 22, 2013, 4:44pm
2
Replace double quotes "
with single quotes '
awk '{s+=$0} END {print s}' es.out
I tried that just now - same result.
Show the input you have and the output you want.
The input is a file with a different number on each line (es.out) - I want to add the numbers for a total in the output file (es.cnt)
Input -
252
428
1174
12
29
539
35
12
30
7
6
3
5
Output -
2532
Works fine here, but try $1 instead of $0. Maybe your version of awk refuses to add numbers with whitespace in front of them.
Works perfectly now! Thank you so much!!!