Lets say I have a line like this:
<group description="" name="voice_guidance" comment="Missing description!" status="0">
I wish to grep with a bash script only the comment saying:
Missing description!
Lets say I have a line like this:
<group description="" name="voice_guidance" comment="Missing description!" status="0">
I wish to grep with a bash script only the comment saying:
Missing description!
If you only want the comment, you can use this:
grep -Po 'comment="\K[^"]*'
\K
means to only output the part following from there and then all the non-quote characters following are output.
You can use straightforward solution:
grep '"Missing description!"' filename.html
Where filename.html
is a target file.
Here is an example output:
P.S. In such when I see HTML and RegEx both present in the same question, I recommend to read this answer: https://stackoverflow.com/a/1732454/5091346
If you can't use the perl-regexp (-P
) in @rubystallion's fine answer, use:
$ grep -o "comment=\"[^\"]\+" file | grep -o "[^\"]\+$"
Missing description!