wak 多行语句 sed多个字符替换

来源:互联网 发布:销量数据分析ppt模板 编辑:程序博客网 时间:2024/06/03 19:33
#awk执行多个if语句
cat /test/filename.log|awk '   {{if(/id/){su(/>[^<]*</,">BJ0<")}}                \
                                                   {if(/name/){su(/>[^<]*</,">BJ1<")}}          \
                                                   {if(/sex/){su(/>[^<]*</,">BJ2<")}}              \
                                                   {if(/age/){su(/>[^<]*</,">BJ3<")}}             \
                                                   {if(/address/){su(/>[^<]*</,">BJ4<")}}    \
                                                  print}' >>/test/filename2.log    #重定向到文本文件当中
       
#sed多个替换
cat /test/filename2.log|sed -e   "s/ggg/999/g;    \
                                                         s/qwe/999/g;   \
                                                         s/iif/999/g;        \
                                                         s/mnm/999/g; \
                                                         s/www/999/g"    >>/test/filename3.log