To make a long story short, I have a line of text that I'm using grep to see if the letter 'd' exists here is an example of what is going on:
echo d file='hello world' | grep -c -w d
Returns 1, this is correct.
echo file='hello world' | grep -c -w d
Returns 0, this is correct.
echo d file='hello world d' | grep -c -w d
Returns 1, this is correct
echo file='hello world d' | grep -c -w d
Returns 1, this is INCORRECT.
The problem is that I need it to ignore the data inside the single quotes. The last example needs to return 0. I'm more of a C# regex guy and less of a Linux grep guru. Can anyone point me in the right direction. Is grep the right tool to use here or is there something else that might help?