I have a simple executable awk script which I'm trying to make to say its own name:
$ cat script.awk
#!/usr/bin/awk -f
BEGIN {
print "Hi, I'm " ARGV[0]
}
when executed:
$ chmod u+x script.awk
$ ./script.awk
Hi, I'm awk
Expected (well, desired anyway) output would be Hi, I'm script.awk
. Is there a way to achieve that except turning it to a shell script, like:
$ cat script.sh
#!/bin/bash
read -d '' script <<EOF
BEGIN {
print "Hi, I'm " var
}
EOF
awk -v var=$0 "$script"
aaand, action:
$ ./script.sh
Hi, I'm ./script.sh