next
Stop processing the current input record. The next input record is read and processing starts over with the first pattern in the AWK program. If the end of the input data is reached, the END block(s), if any, are executed.
举个例子:
cat file
1 a
2 b
3 c
4 d
awk '/^3/{print $2;next}{print $0}' file
1 a
2 b
c
4 d
如果匹配不到开头为3的记录,就打印$0
如果匹配到了开头为3的记录,就打印$2,这里如果没有next,会继续再打印$0
awk '/^3/{print $2}{print $0}'
1 a
2 b
c
3 c
4 d
next就是读取下一条记录,再从头执行代码
阅读(1491) | 评论(0) | 转发(0) |