Quote:
Originally Posted by sopier
Just curious with the meaning of 1 in the end of the code?
|
Think about the general structure of an awk program: you have different rules whose syntax is
Code:
pattern { action }
pattern { action }
...
If you omit the action, the default is applied, that is
print $0 or
print alone, which simply prints the entire record (line). Now the pattern: it can be a logical expression, a regular expression, a range and so on. If it is a logical expression it is evaluated as TRUE or FALSE. Since in awk true and false are a non-zero (or a non-empty string) and 0 (or an empty string) respectively, you can use 1 or any other number different than 0 to state TRUE.
In brief, your rule is made of an expression without action, the expression is TRUE and the default action is applied, that is the whole line is printed out.