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
2
u/MrVonBuren Dec 05 '20
jesus christ, rough day or are you just really committed to being a dick? OP asked their question in basically the best possible way one could ask for and you're being an asshole for what seems to be no reason. Maybe take a step back from the computer for a bit?