Linux批量替换多文件文本

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

1.sed+grep方案:

sed -i "s/abcde/vifix/g" `grep abcde -rl /home/test`

2.perl方案:

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

update @2011-11-10:
3. sed+find方案:

find -iname "*.txt" -exec sed -i "s/from_string/to_string/g" {} \;

No Responses

Leave a Comment

(Necessary)

(Necessary, will not be published)

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.