Chinaunix

标题: 批量替换文件内容 [打印本页]

作者: littleboywj    时间: 2007-12-31 23:45
标题: 批量替换文件内容
使用sed
ls -1 * | awk '{print "sed s#/style.css#/blog/styles_zh-cn.css#g "$1" > ../"$1
}' > sed.sh
sed -in-place -e 's/abc/cba/g' *
使用 perl:
perl -pi -e 's|ABCD|Linux|g' `find ./ -type f`
使用iconv 替换编码
如将GBK 替换为 UTF-8:
#!/bin/sh
for file in `ls *.jsp`
do
  echo $file
  iconv -f GBK -t UTF-8 $file -o src/$file
  echo "Proceesing file $file"
done
               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/2925/showart_454110.html




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2