PDA

View Full Version : Using bash to print the third word in a line



fasoulas
March 19th, 2011, 02:39 PM
Is there a way to print out the 3rd word of a line found in a file?

Can i do this with grep??

sisco311
March 19th, 2011, 02:55 PM
awk is probably a better choice:

awk '/PATTERN/{print $3}' file

fasoulas
March 19th, 2011, 02:57 PM
awk is probably a better choice:

awk '/PATTERN/{print $3}' file

ok thanks a lot
i did
awk '{print $3}' file and it worked