cancel
Showing results for 
Search instead for 
Did you mean: 
Trevor
Starfighter Starfighter
Starfighter
  • 106 Views

awk Tip - #1

$ awk  -F:  '{ OFS = "\t\t"; print $1,$3 }'  filename

 

awk is comprised of several built-in variable.  The OFS variable is one that
is used to specify the character that will be used as the separator between
fields of information.  By default, the space character is used for the OFS
variable.

Assuming a file is comprised of at least three colums/fields of data, with
each column/field separated by a colon (:) character, the command above
will output only columns/fields 1 and 3, with 2 tabs between each column/field.

Try the above command on a file containing the following data:

Joseph:Jerome,Jones
Jessie:Wayne:Smith
Lonnie:Earl:Green
Laura:Ethel: Austin

 

 

 

Trevor "Red Hat Evangelist" Chandler
0 Kudos
0 Replies
Join the discussion
You must log in to join this conversation.