How to use loops in awk
This article introduces the knowledge of "how to use loops in awk". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
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-f BEGIN {# Loop through 1 to 10 iTunes 1; while (I