Is print a function or statement.
Why parentheses are not required?
I couldn't find any information about this topic.
Is print a function or statement.
Why parentheses are not required?
I couldn't find any information about this topic.
print is a statement that doesn't require (but optionally accepts) parentheses.
The entire list of items may optionally be enclosed in parentheses. The parentheses are necessary if any of the item expressions uses the `>' relational operator; otherwise it could be confused with a redirection
(see The print Statement)
Some people always use the parentheses, because e.g. they prefer the function syntax and it has no negative side effects.
printis a statement. Both understandings are problematic though. The first because on some (but not all) awk implementations, any expression can occur in a statement context, so on this understanding all expressions would be statements. The second because assignments and user-defined function calls return values but the first is indisputably and the second is disputably a statement. – dubiousjim Apr 19 '12 at 11:18getlineis one example, and on some implementations of awk, you can uselengthwithout parentheses as a shorthand forlength($0). – dubiousjim Apr 19 '12 at 11:20length(print $1), that doesn't make sense. But you can dolength(sprintf("%s", $1)). – darkfeline Oct 24 '17 at 06:26