[thelist] Any AWK experts? FILENAME help needed

Jay Blanchard jay.blanchard at niicommunications.com
Wed Apr 17 08:38:09 CDT 2002


Good morning!

Don't let my bright and shiny disposition fool you, I am beating my head
against the wall this morning.

In Linux I have an AWK script which parses other large text files into
comma-delimited files, which are then imported into the database. I run the
AWK script from the command line thusly;

cat thefiletobeparsedname | parse.proc

It occured to us that we would like to have the file's name and the line
number for each record inserted into the database as well. The line number
is no problem (used AWK's NR), but the file name is giving me fits. AWK
provides a variable that holds the file's name (FILENAME) but this variable
contains "-" when the file name is passed from the command line. I have been
searching the web over for info on this, even my O'Reilly on AWK provides no
insight. (I know I can do this if I automate the script, but that is just
not feasible at the moment.)

TIAFAYH!

Jay





More information about the thelist mailing list