为此:
grep -lr -e index *.html | xargs sed -i .bak -e s#<!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=UTF-8"><!-- /Added by HTTrack -->##g
但是,如果你想要修改的文件contain<>/strong>index
,这只会奏效。 如果您希望修改所有<代码>index.html,现名录及其子标题下的文档均使用:
find . -name index.html | xargs sed -i .bak -e s#<!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=UTF-8"><!-- /Added by HTTrack -->##g
Either way, the important thing was to replace /
with #
in the sed s s command. This command allows you to use almost any separator as long as you re consistent (i.e. all three separators are the same character). You should pick the separator that does not appear in your expression or you have to escape it there.
Also note that I modified flags to sed. From sed man page:
-i extension
Edit files in-place, saving backups with the specified extension. If a zero-length extension is given, no backup will be saved. It is not recom-
mended to give a zero-length extension when in-place editing files, as you risk corruption or partial content in situations where disk space is
exhausted, etc.
-e command
Append the editing commands specified by the command argument to the list of commands.
This means that my commands will save every file as a backup before modifying and append .bak to the backup file s name. If you don t want the backups pass the zero-length extension like this: -i
.
普通表达方式不够有力,不足以达到超文本。 在这里,它只是因为你拥有一个固定的级的特性,以取代刚刚变成“超”的特性。