awk-for循环简单用法
文本:
|
1
2
3
4
|
[root@VM_0_84_centos ~]# cat sshd.txt1 2 34 5 67 8 9 |
循环打印上述文本
for 循环的固定格式 i=1设置i的初始变量 i<=NF i变量小于等于 NF变量的值(每行的字段数) i++ 表示i递增+1,
|
1
2
3
4
5
6
7
8
9
10
|
[root@VM_0_84_centos ~]# cat sshd.txt |awk '{for(i=1;i<=NF;i++){print $i}}'123456789 |