Home Linux Utils
Print last word of line:

awk '{print $NF}'


Print lines between two lines

awk '/keyword1/,/keyword2/' 


Change the field separator to / and get the last word

/bin/pwd | awk 'BEGIN { FS = "/" } ; { print $NF }'

works also with awk -F "/" '{ print $NF }'


Example to get fields from a .csv into a flat file

awk 'BEGIN { FS = "," } ; { print $2 "  " $9 }' /path/to/file.csv | sed 's/"//g'
 

Remove line  if  2 field is empty

awk  '$2!=""'


Use printf instead of print to print without the newline

Also see  cut