0

I have several html files within subfolders which have a redundant link like:

<link rel="stylesheet" href="../demos.css">

I am trying to remove this line from all the html files using the following command in linux:

find -name '*.html' -exec sed --in-place=.bak 'demos.css' "{}" ;

But this gives me the following error:

find: missing argument to `-exec'

Yes of course I have checked all the solutions on Stackoverflow related to this but most of them are regarding a single file and the rest don't help. What am I doing wrong with this code?

1

3 Answers 3

2

find is missing starting path, sed is missing d command and you need to escape the semi colon in find command:

find . -name '*.html' -exec sed -i.bak '/demos\.css/d' '{}' \;

Or better:

find . -name '*.html' -exec sed -i.bak '/demos\.css/d' '{}' +
Sign up to request clarification or add additional context in comments.

7 Comments

I am getting an error like this sed: -e expression #1, char 2: extra characters after command -in both cases.
In the first case I am getting this error several times and in the second one I am getting it only once.
Still the same error. I don't understand why, it seems alright!
Yes. Exactly like you posted.
If it worked out, please consider accepting the answer.
|
0
for i in `find /www/htmls/ -name "*.html" 2>/dev/null`
do
    sed -i 's/^demos.css.*//' "$i"
done

1 Comment

While this code block may answer the question, you always should provide some explanation for why it does so.
0

try this please:

for i in `find /www/htmls/ -name "*.html" 2>/dev/null`
do
    sed -i '/demos\.css/d' "$i"
done

2 Comments

Does not give any error but does not change the html files either.
sorry, escape the "."

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.