matt
matt

Reputation: 53

Exclude lines by pattern in sed

I'm trying write a sed command in bash that updates all references to javascript and css files in an HTML file with $(name).min.js, however I want to ignore files with the word MANAGER_WIDGET in the path e.g.

Replace:

<script type="text/javascript" src="javascript/scripts.js"/>

But not:

`<script type="text/javascript" src="$MANAGER_WIDGET/Common/API/Plugin.js"/>`

So far I've got the following sed command which adds .min to all files js and css files:

sed "s/\.\([jscss]\+\)\"/\.min\.\1\"/g" index.html

It would be great if someone can show me how I can also exclude lines with MANAGER_WIDGET in them.

Upvotes: 5

Views: 2737

Answers (1)

ezod
ezod

Reputation: 7411

sed '/MANAGER_WIDGET/!s/\.\([jscss]\+\)\"/\.min\.\1\"/g' index.html

Upvotes: 9

Related Questions