AWK
Example
> cat Text.txt
1
2
3
4
5
If you want to get the sum of this column, you can use the tool awk.
cat Text.txt | awk '{sum += $1} END {print sum}'
Output:
15
If you want to show the information of the file together with the sum, you can enter the command as below
cat Text.txt | awk '{sum += $1} {print} END {print sum}
Output:
1
2
3
4
5
15
AWK
The AWK utility is a data extraction and reporting tool
Wiki page: http://en.wikipedia.org/wiki/AWK
Reference:
vbird:
沒有留言:
張貼留言