cancel
Showing results for 
Search instead for 
Did you mean: 
Trevor
Commander Commander
Commander
  • 368 Views

awk Tip - #8

To print the first and last fields of each line, from a file named DATA:

              $  awk  '{print  $1, $NF}'  DATA

 

Trevor "Red Hat Evangelist" Chandler
Labels (3)
1 Reply
Chetan_Tiwary_
Community Manager
Community Manager
  • 322 Views

fun fact : you can use -F to split the data using the delimiters in the file.

eg.                           awk -F',' '{print $1, $NF}' DATA

for more details, here is to look for : https://learn.redhat.com/t5/Platform-Linux/Using-awk/td-p/47220

Also do you guys know awk is an acronym that is formed from the last names of its brilliant creators: Alfred Aho, Peter Weinberger, and Brian Kernighan (AWK ) 

Join the discussion
You must log in to join this conversation.