Quantcast
Viewing latest article 6
Browse Latest Browse All 6

How 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". Besides, ARGV[i] with i>0 is used only for script arguments in command line. So, how to make it print the name of the script, in this case "myscript.awk"?


Viewing latest article 6
Browse Latest Browse All 6

Trending Articles