Reputation: 3756
How to chain grep to match images between double quotation marks?
$ cat final.html | grep -Po 'src=\".*?\"'
src="Remix-OS-Download-Option.png"
src="VMSetup1.png"
src="VMSetup2.png"
src="VMSetup3_001.png"
src="VMSetup4.png"
src="VMSetup5.png"
src="VMSetup6.png"
Expected result:
Remix-OS-Download-Option.png
VMSetup1.png
...
VMSetup6.png
Upvotes: 3
Views: 1064
Reputation: 15141
Hope this will be helpful. As we are using perl regular expression here you can check demo here
Pipe your Command with: grep -Po '="\K[^"]+'
Regex: ="\K[^"]+
1.
="\K
this will match="
and\K
will reset the current match.2.
[^"]+
match all except"
Complete command:
cat final.html | grep -Po 'src=\".*?\"' | grep -Po '="\K[^"]+'
Optionally you can try this one: cat final.html | grep -Po 'src="\K[^"]+'
Upvotes: 3