current directory in awk

Hello,

I want to use the string with the current directory in my awk command.
I tried: 'pwd=system("pwd")'

but it doesn't work. can please help somebody?

$ awk -v P="$(pwd)" 'BEGIN{print P}'
/home
pa=getline mypwd; printf pa

output: 1

EDIT:

found the static array 'ENVIRON' in manual.

works:

pa=ENVIRON["PWD"]; printf pa
2 Likes