It often happens to me that I have errors when doing if-else, I don't know when to put semicolons or when to use curly braces.
What is the way to write a if-elif-else
correct in Awk?
It often happens to me that I have errors when doing if-else, I don't know when to put semicolons or when to use curly braces.
What is the way to write a if-elif-else
correct in Awk?
The structure of a condition
if
in Awk is of the form:If you want to put a "counterpart" in the form of
if-else
you can say:Or even add some
elif
of the form:As usual in Awk, if a block has only one statement, you can omit the curly braces and simply say:
Of course, if you are working on a single line, remember that each line break must have its corresponding semicolon, so you would say:
For example: