Showing posts with label cut. Show all posts
Showing posts with label cut. Show all posts

Monday, October 15, 2012

cut vs awk in linux

In linux for selecting columns we generally use cut command. The problem with cut is that we can give delimiter of length 1 only. In case the columns have variable spaces in the output then cut fails.

In such situation awk come for the rescue.

Syntax : awk '{print $2, $3}' 

Here $2, $3 are the column we want to print. These columns can have multiple spaces between them

More links :

http://linux.about.com/library/cmd/blcmdl1_awk.htm

http://lowfatlinux.com/linux-awk.html