先前用过了,省得自己不记得,好记性不如烂笔头。记下吧。

将某目录中所有文件中的文本“abcde”替换成“12345”:

1.sed方案:

sed -i "s/abcde/12345/g" `grep abcde -rl /path`

2.perl方案:

perl -p -i -e "s/abcde/12345/g" *

另 文件批量改名rename也相通

如  rename

rename s/x/y/ *.abc  #修改所有的包含_的.abc文件中的x为y

Related posts:

  1. 安装Nginx

Tags:

8 Comments to “linux批量替换”

  1. longines says:

    不错的小技巧

  2. julf says:

    我哪最近多了很多垃圾评论。为啥呢..

  3. julf says:

    能申请,我还说啊..汗

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>