Import variables in to awk.

Randal Schwartz merlyn at iwarp.intel.com
Thu Nov 16 12:01:26 AEST 1989


In article <10531 at thorin.cs.unc.edu>, warner at unc (Byron Warner) writes:
| My questions is how do you import csh variables into an awk script.
| for example if I have a file called foo, which contains:
| {
| 	print import,$0
| }
| 
| and I issue the command 
| awk -F: -f foo /etc/passwd import='hello
                                          ^ missing quote,  perhaps?
| why do I get just a list of logins?

The order of command-line options is significant:

% awk -F: -f foo import='hello' /etc/passwd

yields the result you want.  Also note that these variables are not
available in the "BEGIN" action (unless something happened after the
V7 version of awk).

Just another UNIX old-timer,
-- 
/== Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ====\
| on contract to Intel's iWarp project, Hillsboro, Oregon, USA, Sol III  |
| merlyn at iwarp.intel.com ...!uunet!iwarp.intel.com!merlyn	         |
\== Cute Quote: "Welcome to Oregon... Home of the California Raisins!" ==/



More information about the Comp.unix.questions mailing list