To print the filename with awk on Linux or Unix, you can use the FILENAME built-in variable. FILENAME is a predefined variable that contains the name of the current input file.
Here is an example of how you can use FILENAME to print the filename with awk:
awk '{print FILENAME}' file.txt
This will print the name of the file, file.txt, to the terminal.
You can also use FILENAME in an awk script to perform actions based on the filename. For example, the following awk script will print the filename and the first field of each line in the file:
awk '{print FILENAME ": " $1}' file.txt
This will print output like the following:
file.txt: field1 file.txt: field1 file.txt: field1