Awk

From Hackepedia
Revision as of 08:41, 14 December 2005 by Franks (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

I wanted to find out how much resident memory xfce4 was using on my system, and it appears most xfce applications start with "xf":

$ ps auwx | grep xf | awk '{print $5}'
15924
14668
11948
11764
12944
16264
1860


I wanted to use awk to add the results together instead of doing it manually:

$ ps auwx | grep xf | awk '{ tot += $5 } END { print tot }'
69108