AWK - Eric's questions

Krzysztof Suchecki <[email protected]> Fri, 8 Nov 2002 07:38:04 +0100
Newsgroups gmane.os.freedos.devel
Organization Poczta Wirtualnej Polski S.A. http://www.wp.pl/
Message-ID <[email protected]>
I went through "AWK Language Programming. A User's Guide for GNU AWK"
by A.D.Robbins describing GAWK 3.0 and tested GAWK 3.0.3 for DOS
(taken from Gnuish package)

1. CURRENT DRIVE / DIRECTORY / PARTING FILENAMES.
-------------------------------------------------

The only thing you have in AWK is the FILENAME variable which is
current data file's name. If you supply sth like:

 awk -f prog.awk c:\bla\bla\bla\very_imp.dat

FILENAME will be 'c:\bla\bla\bla\very_imp.dat'
and it may be useful.

But if you supply

 awk -f prog.awk \bla\very_imp.dat
or
 awk -f prog.awk very_imp.dat

it won't be useful.

You may ask: "How does AWK know where is located?"
It simply doesn't know. AWK is the one-file prog.

14.3 says:
=========================================
If the file name supplied to the '-f' option does not contain
a '/', then gawk searches a list of directories (called search path), one by
one, looking for a file with the specified name.
 The search path is a string consisting of directory names separated by
colons. gawk gets its search path from the AWKPATH environment variable.
If that variable does not exist, gawk uses a default path, which is
'.:/usr/local/share/awk' (2)

(2) Your version of gawk may use a directory that is different than
'/usr/local/share/awk'; it will depend upon how gawk was built and
installed. The actual directory will be the value of '$(datadir)'
generated when gawk was configured.
=========================================


2. Setting variables in environment
-------------------------------------------------

You can READ variables but NOT SET (not yet).

10.2 says:
=========================================
ENVIRON - An associative array that contains the values of the environment.
The array indices are the environment variable names; the values
are the values of the particular environment variables. For
example, ENVIRON["HOME"] might be '/home/arnold'. 

Changing this array does not affect the environment passed on to any
programs that awk may spawn via redirection or the system
function. (In future version of gawk, it may do so.)
=========================================

I haven't tested any version of GAWK higher than 3.0.3.

Keep in mind, that awk was designed as text processing tool,
not a system prog.



Chris

-----------------------------------------------------------------------
Prawdziwe okazje nie zdażają się często!
Sprawdź ofertę! < http://zakupy.wp.pl >