Welcome to the Linux Foundation Forum!

AWK Script error?

Hi all: Just learning AWK, and created this script in a file called readfile.awk:

BEGIN {
if ( NR == FNR ) {
n[$1] = 0
} else {
if ( FNR in n ) {
gsub("roger", "johnny", $0)
}
print
}
} users.txt before.txt > after.txt

and I tried to run it: awk -f readfile.awk, but I get errors:

awk: readfile.awk:10: } users.txt before.txt > after.txt
^ syntax error
awk: readfile.awk:10: } users.txt before.txt > after.txt
^ syntax error

Can anyone spot what I am doing wrong?

Thanks for any and all input!

Comments

  • fcioanca
    fcioanca Posts: 1,581

    Hi @johnstraumann

    Is this post related to a particular course? Which one? As this course forum is definitely not the right one.

    Regards,

    Flavia

Categories

Upcoming Training