首页 > 代码库 > awk命令小记2之actions

awk命令小记2之actions

本章主要讲actions中的控制语句,和C语言的控制语句类似。

1.选择语句

if (condition)
    then-body
else 
    else-body

 

2.循环语句之while:

while (condition)
  body

3.循环语句之do-while:

do
  body
while (condition)

 

4.循环语句之for:

for (initialization; condition; increment)
  body

 

5.循环语句之switch:

switch (expression) {
case value or regular expression:
    case-body
default:
    default-body
}

6.循环语句之continue,break

awk命令小记2之actions