If you want to check the exact string == opeator will be the better choice.
If you want to check the part of the string then pattern match would be better and has more variety of options and more powerful.
The /.../ denotes a regular expression, which can include wildcards etc., against $3 will be matched. The matching operator is ~
The "..." denotes an exact string that can be matched, or can be used for an equality check (operator == ).
Actually, while staring at it, I can't see why the == doesn't like the regex.
@rangarasan:
Here you are checking the exact string "/blue/" instead of "blue" with the third column.
Sorry, I disagree. Exact string needs to be double quoted. So I think it still is a regex that awk doesn't like in that place.
The | is used as an or operator when matching regexs ONLY. If you try == on it, it searches for the exact string including | in your input.
I think you need to understand the difference between "matching" and "comparing".
The only meaningful difference is with the ~ operator ( / .. / cannot be used with the == operator )
There is a difference between " .. " (string interpreted as ERE) and / .. / (ERE constant)
Compare:
$ echo '|a' | awk '$0~/\|a/'
|a
$ echo '|a' | awk '$0~"\|a"'
awk: illegal primary in regular expression |a at a
$ echo '|a' | awk '$0~"\\|a"'
|a
" .. " allows for concatenations with variables, whereas / .. / does not...
There is no problem, but the same difference applies between " .. " and / .. /
So that is not correct: the first matches the regex that contains blue and the second one as well...