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?

HackCode
  • 1,837
  • 6
  • 35
  • 66

3 Answers3

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' '{}' +
anubhava
  • 761,203
  • 64
  • 569
  • 643
0

try this please:

for i in `find /www/htmls/ -name "*.html" 2>/dev/null`
do
    sed -i '/demos\.css/d' "$i"
done
poll0rz
  • 11
  • 3
0
for i in `find /www/htmls/ -name "*.html" 2>/dev/null`
do
    sed -i 's/^demos.css.*//' "$i"
done
candymanuu
  • 110
  • 7
  • 4
    While this code block may answer the question, you always should provide some explanation for why it does so. – Sascha Wolf Feb 23 '15 at 16:01