Sunday, May 07, 2006

Some occasions where you can replace awk with cut

Let me tell you first that I love awk and its my favourite scripting language.But in case you just have a one time simple requirement for column processing and you don't know awk , in some cases you can fulfil the requirement with cat and cut

cat inputfile | cut -f 6 -d ' '
where the sixth column would be output when space is the delimiter.

the awk equivalent would be
awk -F ' { print $6 } ' inputfile

"And yet they said awk is difficult
But Awk is a wonderful tool"

No comments: