check if line containing string is commented
I need to create a bash script that searches through a file, finds a word, and if that line containing this word is commented, echoes it.
I imagine it would be something like this, but I don't know exactly how to do it. Quote:
|
what do you mean by "commented"?
|
Sorry I wasn't clear. By commented I mean to have a # at the start.
|
so you need to find lines beginning with # and containing a specific word?
A single grep command can be do that, you just need to be familiar with it: Code:
grep <pattern> filename ^ means the beginning of the line, so: grep ^# filename will look for lines beginning with #. grep word filename will look for lines containing word. You may need to combine this to get the required result and also may take into account if word contains special chars. See man grep about regular expressions understood... |
this helped. Thanks
|
All times are GMT -5. The time now is 02:38 AM. |