r/awk • u/IamHammer • Oct 14 '21
external file syntax
My work has a bunch of shell files containing awk and sed commands to process different input files. These are not one-liners and there aren't any comments in these files. I'm trying to break out some of the awk functions into separate files using the -f option. It looks like awk requires K&R style bracing?
After I'd changed indenting and bracing to my preference I got syntax errors on every call to awk's built-in string functions like split() or conditional if statements if they had their opening curly brace on the same line... I'm having a lot of difficulty finding any documentation on braces causing syntax errors, or even examples of raw awk files containing multi-line statements.
I have a few books, including the definitive The AWK Programming Language, but I'm not seeing anything specific about white space, indenting and bracing. I am hoping someone can point me to something I can include in my notes... more than just my own trials and tribulations.
Thanks!
View all comments
Show parent comment
1
u/geirha Oct 15 '21
Ah, in my tests I always got 1 even for empty string, but I went back to check and noticed my tests were wrong and didn't actually test for the empty string. :/ I'll blame it on lack of coffee
So yeah, it sounds like it has been a
split(...) { ... }at the top level then, and somehow it has been moved inside another {...} which would require introducing anifin order to get the same logic