Advertisement
metalx1000

Adding Columns with AWK

Aug 7th, 2017
643
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.32 KB | None | 0 0
  1. #example File1
  2. bob smith 100
  3. tim zim 123
  4. ted fred 450
  5. bob hill 543
  6.  
  7. #get the sum of column 3
  8. awk '{total += $1} END {print total}' File1
  9.  
  10. #example File2
  11. bob smith $100
  12. tim zim $123
  13. ted fred $450
  14. bob hill $543
  15.  
  16. #remove the '$' and then get sum of column 3
  17. awk '{gsub(/\$/,"");total += $3} END {print total}' File2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement