Friday, January 10, 2014

Adding things up on the cli

Need to add up a column real quick on a linux file? Use awk for a quick add.



Awk will eventually use scientific notation for very large numbers unfortunately.


This is where you can use paste and bc. The command 'paste -sd+' will output the file contents as line1+line2+etc. This is essentially just formatting for input in to bc. Very useful when adding up large numbers in a file.

paste -sd+ | bc

No comments:

Post a Comment