What do awk scripts do?

I found this in the built-in Makefile:

awk '/@/{print "  \"" $$_ "\\n\"" }' file

I know the awk prototype:

awk 'pattern {action}' file

But what does @u mean $$_?

+3
source share
2 answers

The underscore seems to be just a variable in this case. And since it is not initialized, it has a value of 0. Thus, it is $_equivalent $0, which applies to the entire line being processed. I think it could also be written $x, since x would be an uninitialized variable.

Since it appears in the makefile, you need two dollar signs (this is a special character in the makefile) to create one dollar sign in the command.

Nemo, @ - . , @, .

+2

, . , , , :

awk '/@/{print "  \"" $_ "\\n\"" }' file

, :

awk '/@/{print "  \"" $0 "\\n\"" }' file

, foo@bar "foo@bar\n" ( ). @ , .

$_ , ...

+1

All Articles