Here's a Linux command to add numbers inside a file:
[root@myserver misc]# cat num.test
1
2
3
4
5
This is a sample file with only 5 lines. Think of a file with millions of lines. Either you can do with MS - Excel, which may hang(!!) or use Linux command - 'awk'- which is powerful and easier:
[root@myserver misc]# awk '{s+=$1} END {print s}' num.test
15
As simple as that..!!
[root@myserver misc]# cat num.test
1
2
3
4
5
This is a sample file with only 5 lines. Think of a file with millions of lines. Either you can do with MS - Excel, which may hang(!!) or use Linux command - 'awk'- which is powerful and easier:
[root@myserver misc]# awk '{s+=$1} END {print s}' num.test
15
As simple as that..!!
No comments:
Post a Comment
Note: only a member of this blog may post a comment.