AWK to perform like GREP
Hi guys,
Im trying to use awk to do matching in only a specific column example.txt: www.google.com www.example.com www.google.com/search www.example2.com i used: awk '{ (if $1 == "http://www.google.com") print $2}' example.txt this awk statement only returns the first line, and i cant seems to make it perform in a way to match based on keywords like GREP. Is there any way to make display the other lines which contains "google" also? |
Hi,
If you want to search field one for (part of) a string: awk '$1 ~ /www.google.com/ { print $2 }' example.txt If the search string should match anywhere in the line (all fields): awk '/www.google.com/ { print $2 }' example.txt Hope this helps. |
All times are GMT -5. The time now is 02:11 AM. |