21.07.2015 Views

GAWK: Effective AWK Programming

GAWK: Effective AWK Programming

GAWK: Effective AWK Programming

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

236 <strong>G<strong>AWK</strong></strong>: <strong>Effective</strong> <strong>AWK</strong> <strong>Programming</strong>If there are no fields left after removing all the punctuation, the current record is skipped.Otherwise, the program loops through each word, comparing it to the previous one:# dupword.awk --- find duplicate words in text{$0 = tolower($0)gsub(/[^[:alnum:][:blank:]]/, " ");$0 = $0 # re-splitif (NF == 0)nextif ($1 == prev)printf("%s:%d: duplicate %s\n",FILENAME, FNR, $1)for (i = 2; i

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!