linux 下使用一下命令可以替换一个目录下面所有的正则匹配到的字符串
{% highlight Bash shell scripts %}
sed -i “s/origin_string/replace-string/g” grep origin_string -rl /path
{% endhighlight %}
多行字符串替换, 注意 &
符号需要用 &
替换
{% highlight Bash shell scripts %} sed -i ‘s#
November 27, 2012
linux 下使用一下命令可以替换一个目录下面所有的正则匹配到的字符串
{% highlight Bash shell scripts %}
sed -i “s/origin_string/replace-string/g” grep origin_string -rl /path
{% endhighlight %}
多行字符串替换, 注意 &
符号需要用 &
替换
{% highlight Bash shell scripts %} sed -i ‘s#
#\n\n\n#g’ grep '</body>' -rl src
{% endhighlight %}
替换测试
{% highlight Bash shell scripts %} echo ”” | sed -e ‘s##\n\n\n#g’ {% endhighlight %}