awk partly string match (if column/word partly matches)
My dummy file looks like this:
C1 C2 C3
1 a snow
2 b snowman
snow c sowman
I want to get line if there is string snow
in $3. I can do this like this:
awk '($3=="snow" || $3=="snowman") {print}' dummy_file
But there should be more simpler way.
awk '$3 ~ /snow/ { print }' dummy_file
Also possible by looking for substring with index() function:
awk '(index($3, "snow") != 0) {print}' dummy_file
Shorter version:
awk 'index($3, "snow")' dummy_file
Maybe this will help
http://www.math.utah.edu/docs/info/gawk_5.html
awk '$3 ~ /snow|snowman/' dummy_file