极湖

无不用其“极”

用命令一次替换多个文件中的字符串

, ,

下面这个命令,不时要翻出来用一下:

find /path/to/ -name "*.html" -type f | xargs grep -l -e "StringOrPattern" | xargs -n 100 perl -e "s/StringOrPattern/AfterReplace/g;" -pi

没有 Perl 的 Linux/Unix 环境应该很少吧?如果没有perl,这个命令可不好使。

命令太长,难记,因此在这儿纪录一下。

.qmail-xxx 文件中的符号没有一天不Google

Write a comment

You must be logged in to write a comment. If you're not a registered member, please sign up.

February 2012
S M T W T F S
January 2012March 2012
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29