+ -

:shell awk 传参 awk变量匹配

时间:2010-12-05

来源:bugouhen

在手机上看
手机扫描阅读
此文章为转载!因没记住地址 对原著表示感谢
标签:shell awk 传参 awk变量匹配 按关键子分文件   1 为关键字文件  2为数据文件 知识点 1. shell 向awk 传递参数  -v  filename=$i 2. awk 匹配变量  /'$i'/ 3. awk 写文件  print $0 >  filename
[root@test shell]# cat 1 aa bb [root@test shell]# cat 2 aacc bbdd aaee bbff aawww cc 11 22 33 [root@test shell]# cat test
for  i in  `cat 1` do awk  -v filename=$i '{if($1 ~/'$i'/){print $0 > filename}}' 2 done [root@test shell]# sh test [root@test shell]# ls 1  2  3  4  5  6  7  8  aa  bb  difip  echo  ip  spawn.sh  test  txt2  while [root@test shell]# cat aa aacc aaee aawww [root@test shell]# cat bb bbdd bbff

热门下载

更多