Adding (not replacing) a pattern match with a similar pattern?
I'm writing a bash script to search html files, and when I find any occurrence of an img src tag like this:
<img src="123-picture-normal.jpg" alt="some random user entered text" border="0"> I want to add a second line below it that looks like: <img src="123-picture-thumbnail.jpg" alt="some random user entered text" border="0"> All I need to do is duplicate the line but replace "normal" with "thumbnail" Each file can have multiple img src tags with different numbered jpgs. I have a feeling this is a job for sed, but I'm struggling with it. Any ideas? |
Try
Code:
sed '/<img src="[0-9]*-picture-normal.jpg" alt="/{ |
Excellent - I knew it was possible. Thanks for showing me how.
|
All times are GMT -5. The time now is 11:01 PM. |