Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail From: Bill Marcum Newsgroups: comp.os.linux.misc,comp.lang.awk Subject: Re: HOW2 pass args to awk? Followup-To: comp.os.linux.misc Date: Tue, 17 May 2011 07:55:36 -0400 Organization: Mankind for Ethical Animal Treatment Lines: 25 Message-ID: References: NNTP-Posting-Host: yWgyuajJrLpYZzzKG99Z1A.user.speranza.aioe.org X-Complaints-To: abuse@aioe.org User-Agent: slrn/pre1.0.0-18 (Linux) X-Notice: Filtered by postfilter v. 0.8.2 Xref: x330-a1.tempe.blueboxinc.net comp.os.linux.misc:1131 comp.lang.awk:233 ["Followup-To:" header set to comp.os.linux.misc.] On 2011-05-17, no.top.post@gmail.com wrote: > I had suspected that ARGV could do it. > But it fails. Are you fooling with me? > gawk ' > BEGIN { > arg1 = ARGV[1] > arg2 = ARGV[2] > print "arg1=" arg1 <--- 'arg1' is 'empty'/uninitialised > }' > > exit > /arg1/&&/arg2/{print FILENAME ":" $0}'\ > `find /mnt/p11/PhysicalSpace/DirTest -type f` > In the above script, the gawk command ends at }' . It has no arguments. "exit" is interpreted as a shell command, and the lines after it are ignored. -- "Remember when teachers, public employees, Planned Parenthood, NPR and PBS crashed the stock market, wiped out half of our 401Ks, took trillions in TARP money, spilled oil in the Gulf of Mexico, gave themselves billions in bonuses, and paid no taxes? Yeah, me neither."