Match a pattern and print whole line containing matched pattern.

Well.. I was wondering to capture whole line, when I have already one field, and I did it with the help of my friend via awk.

A simple “awk” trick to match a pattern and print whole line containing matched pattern.

# cat <any_large_file/log>|awk ‘$3 ~ /<pattern to look for>/ {print $_}’

It will match a pattern in 3rd field of supplied file and if pattern found whole row/line will be printed on standard output.

Cheers!!

Advertisements