[thelist] Any AWK experts? FILENAME help needed

Chris Blessing webguy at mail.rit.edu
Wed Apr 17 08:42:01 CDT 2002


Jay-

I believe the problem is that you're cat'ing the file into your script, and
therefore the text it is parsing is coming from stdin as opposed to a file
name.

Is there anyway you can setup your script to take a filename argument
directly?  You could cat it from within the script and off you go.

HTH!

Chris Blessing
webguy at mail.rit.edu
http://www.330i.net

> 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