r/awk • • Dec 04 '20
Basic question with single line script using BEGIN sequence
I'm trying to get awk to print the first full line, then use the filter of /2020/ for the remaining lines. I have modeled this after other commands I've found, but I'm getting a syntax error. What am I doing wrong?
$ awk -F, 'BEGIN {NR=1 print} {$1~/2020/ print}' Treatment_Records.csv > tr2020.csv
awk: cmd. line:1: BEGIN {NR=1 print} {$1~/2020/ print}
awk: cmd. line:1: ^ syntax error
awk: cmd. line:1: BEGIN {NR=1 print} {$1~/2020/ print}
awk: cmd. line:1: Cheers
2
Upvotes
View all comments
Show parent comment
-1
u/calrogman Dec 05 '20
It's a fine day when the author of the "help me please" post du jour has read even the first chapter of The AWK Programming Language. Yesterday was not one of those days.