Scripting / one liner help

Jordon Bedwell jordon at envygeeks.com
Wed Aug 10 22:43:37 UTC 2011


On Wed, August 10, 2011 2:52 pm, Hal Burgiss wrote:
> Its attempting to capture the string in between:
>
> SRC="  and the next doublequote: ".  The [^"] stops the capture at the
> double quote. The capture should then include any character that is NOT a
> double quote. If not careful, the expression could get "greedy" and start
> matching other double quotes on the same line.  This should stop that
> effect. The \1 is a reference back to the capture that is in the
> parenthesis, in sed syntax, which essentially just preserves the captured
> characters, and ignores the rest. Does that make sense?

Because it should be:

grep -iPo "<img[^>]+>" file.html | \
sed -n 's/<img src=['\''"]\([^"'\'']*\).*/\1/pgI'

[COPY AND PASTE BOTH LINES AT ONCE AND PRESS THE ENTER KEY]





More information about the ubuntu-users mailing list