魏长东

weichangdong

正在查看: perl 分类下的文章(第 1 页 / 共 2 篇)

perl类似awk的命令

perl -F"," -anle  '{print @F[2],"\t",@F[3]}'  0318|perl  -anle '{print @F[0],"\t",@F[2]}'|perl  -anlep 's/\//-/g'
perl -F"," -anle  '{print @F[2],"\t",@F[3]}'  0318|perl  -anle '{print @F[0],"\t",@F[2]}'|perl  -anle 's/\//-/g;print'
cat   0318|awk  -F, '{print $3"\t"$4}'|awk '{print $1"\t"$3}'|tr "/" "-"

perl终端输出带颜色

perl -MTerm::ANSIColor -e  "print color 'bold red';print 'hello';print color 'reset';"
perl -MTerm::ANSIColor -e  "print color 'bold red';print \"no match\t$LINE\";print color 'reset';"

 

批量替换 可用sed实现

perl -pi -e 's/ado_link\(/&ado_link\(/g' `find ./ -type f -a -name "*.php"`
perl -pi.bak -e 's/&\s*ado_link\(/ado_link\(/g' *.php