Reputation: 8917
I have many lines of form: A:B:C
I want to print those lines(complete) where the 3rd field (fields separated by :) contain a certain pattern.
Example:
new/old:california/new york:/ms/dist/fx/PROJ/fx/startScript
new/old:startScript/new york:/ms/dist/fx/PROJ/fx/stopScript
When searching for pattern startScript, the 1st line should be printed and not the 2nd one.
Thanks,
Jagrati
Upvotes: 1
Views: 255
Reputation: 838256
The general solution is to use awk but it is worth noting that in your specific example there is a much simpler solution - you can just use grep:
grep 'startScript$' yourfile
Upvotes: 1
Reputation: 75609
Separate on colon, then check third field:
awk -F : '$3 ~ /startScript/ { print }'
Upvotes: 7