I have nested subdirectories containing html files. For each of these html files I want to delete from the top of the file until the pattern <div id="left-
This is my attempt from osx’s terminal:
find . -name "*.html" -exec sed "s/.*?<div id=\"left-col/<div id=\"left-col/g" '{}' \;
I get a lot of html output in the termainal, but no files contain the substitution or are written.
There are two problems with your command. The first problem is that you aren’t selecting an output location for
sed. The second is that yoursedscript is not doing what you want it to do: the script you posted will look at each line and delete everything ON THAT LINE before the<div>. Lines without the<div>will be unaffected. You may want to try:This will also automatically back up your files by appending
.BAKto the original versions. If this is undesirable, change-i.BAKto simply-i.