- 论坛徽章:
- 0
|
文本文件tmp.txt内容如下:
[database]
item = 1 192.168.64.49 root root1234
item = 2 172.25.38.6 root root1234
item = 3 172.25.39.50 root root1234
[t_order_table]
item = 3
[t_cust_table]
item = 1
[t_user_table]
item = 3 0 50
item = 3 51 99
[t_info_table]
item = 3 0 50
item = 3 51 99
awk脚本tmp.awk内容如下:
BEGIN{
FS="[ \t=]+";
}
{
printf("%s, %s\n", $1, $2);
}
执行命令awk -f tmp.awk tmp.txt
结果如下:
[database],
item, 1
item, 2
item, 3
[t_order_table],
item, 3
[t_cust_table],
item = 1,
[t_user_table],
item = 3 0 50,
item = 3 51 99,
[t_info_table],
item = 3 0 50,
item = 3 51 99,
其中后边三个段的$2均无数据,期望应该是item,3这样的结果,请问下谁知道是什么原因吗? |
|