Linked by Thom Holwerda on Tue 27th May 2008 13:08 UTC, submitted by Ward D
General Development AWK is one of the most common UNIX tools to process text-based data in either files or datastreams. Written by Alfred Aho, Peter Weinberger, and Brian Kernighan, AWK "extensively uses the string datatype, associative arrays (that is, arrays indexed by key strings), and regular expressions." ComputerWorld interviewed Alfred Aho.
Permalink for comment 316108
To read all comments associated with this story, please click here.
RE[3]: what an wonderful tool
by Doc Pain on Thu 29th May 2008 20:43 UTC in reply to "RE[2]: what an wonderful tool"
Doc Pain
Member since:
2006-10-08

AWK makes me hate cut.


As you pointed out correctly, there are cases when cut isn't the best tool. But that's tht nature of a tool - use it for what's it good at, and don't use it when it creates more problems than simply using another tool.

Cases where cut is a good tool are, where
1. you just want one of n fields,
2. the field delimiter isn't a space or a tab and
3. when you don't need to care for multiple spaces or tabs.

I remember a case where all three cases were met: I needed a stupid script that would extract all the nicknames from my X-Chat log files, so I did - and don't try this at home, kids - the following stupidity:

cat ${LOGFILES} | grep "<" | grep ">" | grep -v "CTCP" | cut -d '<' -f 2 | cut -d '>' -f 1 | sort | uniq -d | xargs echo > nicklist.txt

After I entered it and saw that it worked, I thought that I'd have better used awk... :-)

Reply Parent Bookmark Score: 2