Question

If this is good awk syntax

awk '{if (0) {print""}}'

and so is this

awk '{if (0) print""; else print ""}'

, then why is this bad syntax??

awk '{if (0) {print""}; else print ""}'
Was it helpful?

Solution

Because the awk conditional syntax is (among others)

if condition compound-statement else compound-statement

Just as in C, by the way. This makes

if condition compound-statement ';' else compound-statement

an error.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top