Awk examples: Difference between revisions

From lippmann wiki
Jump to navigation Jump to search
(Created page with "==ignore first columns and print rest== [maarten.tikal] ➤ echo 'column1 column2 column3 column4' | awk '{print substr($0, index($0,$3))}' column3 column4")
 
No edit summary
Line 3: Line 3:
  [maarten.tikal] ➤  echo 'column1 column2 column3 column4' | awk '{print substr($0, index($0,$3))}'
  [maarten.tikal] ➤  echo 'column1 column2 column3 column4' | awk '{print substr($0, index($0,$3))}'
  column3 column4
  column3 column4
sum all volumes in a column:
awk '{ SUM += $1} END {print SUM }'

Revision as of 21:33, 19 June 2015

ignore first columns and print rest

[maarten.tikal] ➤  echo 'column1 column2 column3 column4' | awk '{print substr($0, index($0,$3))}'
column3 column4
sum all volumes in a column:
awk '{ SUM += $1} END {print SUM }'