Skip to content

Latest commit

 

History

History
24 lines (17 loc) · 576 Bytes

word-count.md

File metadata and controls

24 lines (17 loc) · 576 Bytes

AWK Word count example

We probably all know the wc unix executable which counts:

  • number of lines
  • number of words
  • number of bytes of a given file

We'are going to cover (similar) functionality with small awk program word-count.awk.

Basic example word-count

$ ps auxww > /tmp/ps.log

$ wc  /tmp/ps.log
  389  4737 37752 /tmp/ps.log

$ gawk -f word-count.awk  /tmp/ps.log
  389  4737  37752 /tmp/ps.log

Notes

  • This minimalistic word count example suffers from couple of problems, find at least three of them!