How can I grep the string which is only in uncommented line? I don't want the result to be included for string in commented line. For example: In file.tx
My name is Jane
#My name is Sara
I want to grep word "name" and print the output, like below: -
My name is Jane
But I don't want the commented line to be display to.
Thanks
grep '^[^#]*pattern'
, to prevent any#
from creeping in anywhere before the pattern), may I suggest posting that as an answer?echo "# pattern"
which is not a comment.