How to use loops in awk
This article mainly introduces how to use loops in awk. It is very detailed and has a certain reference value. Friends who are interested must finish it!
The awk script has three main parts: the BEGIN and END functions (both optional), and the functions that the user writes to execute each time. To some extent, the body of the awk is a loop because the commands in the function are executed once for each record. However, sometimes you want to execute multiple commands on a single record, so you need to use a loop.
There are many types of loops that are suitable for different scenarios.
While cycle
A while loop detects an expression and executes the command if the expression is true. When the expression changes to false, the loop breaks.
#! / bin/awk-fBEGIN {# Loop through 1 to 10 iTunes 1; while (I