I have a shell script like the following -
find "." "Account" -maxdepth 1 -name "*.aspx" | xargs awk -f get_controls.awk
It passes multiple files to an awk script
BEGIN{
FS="\""
}
...
/Src=/{
printf("\t%s \r\n", $6);
}
I want to print out the current file name either from the shell script or from within awk at the start of the file.
Awk does know the current file name, it is in the FILENAME variable, but I can't determine the start of the file.
I have tried (NR==1), but all the files are passed to awk as a stream and the value of NR keeps increasing.
Just figured it out as I type this. Will post answer below!