Answer by Ed Morton for How to print own script name in mawk?
With GNU awk 4.1.3 in bash on cygwin: $ cat tst.sh #!/bin/awk -f BEGIN { print "Executing:", ENVIRON["_"] } $ ./tst.sh Executing: ./tst.sh I don't know how portable that is. As always, though, I...
View ArticleAnswer by fedorqui for How to print own script name in mawk?
Using GNU awk Checking the GNU awk user's guide - 7.5.2 Built-in Variables That Convey Information I stumbled upon: PROCINFO # The elements of this array provide access to information about the running...
View ArticleAnswer by cuonglm for How to print own script name in mawk?
With POSIX awk: #!/usr/bin/awk -f BEGIN { print ENVIRON["AWKSCRIPT"] } Then: AWKSCRIPT=test.awk ./test.awk test.awk
View ArticleAnswer by Thor for How to print own script name in mawk?
I don't know any direct way of getting the command name from within awk. You can however find it through a sub-shell. gawk With GNU awk and the ps command you can use the process ID from...
View ArticleAnswer by taliezin for How to print own script name in mawk?
I don't think this is possible as per gawk documentation: Finally, the value of ARGV[0] (see section 7.5 Built-in Variables) varies depending upon your operating system. Some systems put awk there,...
View ArticleHow to print own script name in mawk?
In bash $0 contains the name of the script, but in awk if I make a script named myscript.awk with the following content: #!/usr/bin/awk -f BEGIN{ print ARGV[0] } and run it, it will only print "awk"....
View Article