linux查找包含字符串并替换
Linux 2014/12/20 23:17:03 点击:不统计
linux查找包含字符串并替换
比如将字符串 www.forasp.cn 替换为 forasp.cn
sed替换
grep -rl 'www.forasp.cn' somedir/ | xargs sed -i 's/www.forasp.cn/forasp.cn/g'
sed xargs替换
grep -rl 'www.forasp.cn' ./path | xargs sed -i 's/www.forasp.cn/forasp.cn/g'
perl替换
find -name 'www.forasp.cn' | xargs perl -pi -e 's|www.forasp.cn|forasp.cn|g'
awk替换
grep -i "www.forasp.cn" -r ./path | awk -F : '{print $1}' | sort | uniq | xargs sed -i 's/www.forasp.cn/forasp.cn/g'
原文章%77w%77%2Ef%6F%72%61%73%70%2E%63n
·上一篇:Ubuntu 删除软件 卸载软件全部 >> ·下一篇:linux配置ftp >>