in reply to BEGIN and END with -p or -n
What -n and -p do is wrap something like the following around your code (no, it's not the exact code; just a rough facsimile)
while( <> ) { # -e goes here } continue { print; }
If you have a BEGIN {} or END {} in awk the code in those is run before or after the first line of input is read. So it's in effect saying you get:
## code that was in BEGIN block while( <> ) { ## -e code } continue { print; } ## code that was in END block
|
|---|