Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!sdd.hp.com!hplabs!hpl-opus!steinbac From: steinbac@hpl-opus.hpl.hp.com (Guenter Steinbach) Newsgroups: comp.unix.misc Subject: Re: passing arguments to awk scripts Message-ID: <78670002@hpl-opus.hpl.hp.com> Date: 12 Mar 91 05:41:43 GMT References: <10094@uwm.edu> Organization: HP Labs, High Speed Electronics Dept., Palo Alto, CA Lines: 20 In nawk you can access ARGV and ARGC similar to C. Get the book "The AWK programming language" by Aho, Kernighan (sp?) and Weinberger themselves. Here is a piece of a script that I lifted from the book, it should give you an idea of how this works: nawk 'BEGIN { # deal with args for(i=1;ARGV[i] ~ /^[0-9]+$/;i++) { # collect numbers fld[++nf] = ARGV[i] # into array fld ARGV[i] = "" # remove from ARGV } if(i >= ARGC) ARGV[ARGC++] = "-" # no file name: stdin } # end of BEGIN at this point, only file names or "-" are left in ARGV, and any integer number arguments are collected in fld. Good luck. Guenter Steinbach gunter_steinbach@hplabs.hp.com