[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
is the name of the file being interpreted available?
From: |
Ed Morton |
Subject: |
is the name of the file being interpreted available? |
Date: |
Sun, 19 Jun 2022 10:28:32 -0500 |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 |
I just realised that while shell has $0 to hold the name of the file
containing the script being interpreted, I don't know if that same
information is available in any builtin variable in awk. Obviously I
could write:
awk -v script='/foo/bar/script.awk' -f '/foo/bar/script.awk' input
or similar but is there any way to get that '/foo/bar/script.awk' info
inside the awk script without any manual intervention so I can just write:
BEGIN { "we are running", foo }
for some value of `foo` inside the script to output:
we are running /foo/bar/script.awk
Regards,
Ed.