linux 批量替换
批量替换
1 Find
find -name '要查找的文件名' | xargs perl -pi -e 's|被替换的字符串|替换后的字符串|g'
例子:find ./ -name "*.*" | xargs perl -pi -e 's/\t/111111111/g'
例子:find ./ -name "*.*" | xargs perl -pi -e 's|\t|111111111|g'
2 Sed
find ./ -name "*.*" | xargs sed -i "s/22222/55555555/g"
sed -i "s/aaa/bbb/g" | `grep aaa -rl /home/dir`
grep qweq -rl . | xargs sed -i 's/\t/ /g'
3 Perl
perl -p -i -e | "s/aaa/bbb/g" *.java