View Single Post
  #7   (View Single Post)  
Old 24th August 2010
Carpetsmoker's Avatar
Carpetsmoker Carpetsmoker is offline
Real Name: Martin
Tcpdump Spy
 
Join Date: Apr 2008
Location: Netherlands
Posts: 2,243
Default

There's also cut(1), which is something of a poor man's awk. I've actually never used awk in any shell script.

For example this line:
Code:
SERVER=$(egrep "^SHA256 \($FILE\)" SHA256 | awk '{ print $4 }')
Might be "rewritten" as:
Code:
SERVER=$(egrep "^SHA256 \($FILE\)" SHA256 | cut -f 4 -d ' ')
I find the later to be much more sensible, but that is my personal preference.

It should be pointed out that awk is much more powerful and can do much more than just simple selecting of columns.
__________________
UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things.
Reply With Quote