[thelist] Any AWK experts? FILENAME help needed
Hassan Schroeder
hassan at webtuitive.com
Wed Apr 17 10:24:11 CDT 2002
Jay Blanchard wrote:
> 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.
As Chris Blessing points out, the problem is the FILENAME /is/ "-"
(representing STDIN) when you run the script this way. The only way
to fix that is to run it as
parse.proc thefiletobeparsedname
FWIW!
--
H*
Hassan Schroeder ----------------------------- hassan at webtuitive.com
Webtuitive Design === (+1) 408-938-0567 === http://webtuitive.com
-- creating dynamic Web sites and applications since 1994 --
More information about the thelist
mailing list