*BSD News Article 48698


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!simtel!vtc.tacom.army.mil!ulowell.uml.edu!europa.chnt.gtegsc.com!news.mathworks.com!gatech!swrinde!tank.news.pipex.net!pipex!warwick!brookes.ac.uk!brookes.ac.uk!not-for-mail
From: p0070030@brookes.ac.uk (brownsey ken)
Newsgroups: comp.unix.bsd.bsdi.misc
Subject: awk and variables
Date: 15 Aug 1995 17:45:08 +0100
Organization: Oxford Brookes University
Lines: 34
Message-ID: <40qiuk$bge@cs3.brookes.ac.uk>
NNTP-Posting-Host: cs3.brookes.ac.uk
Summary: How to pass numric variables to awk
Keywords: awk, variables, numeric
X-Newsreader: TIN [version 1.2 PL2]



--
Ken Brownsey
Computing and Mathematical Sciences
Oxford Brookes University
Oxford OX3 0BP
0865-483-683
kwb@brookes.ac.uk

Suppose that I want to list all files greater than max in size.

# for the C shell
BEGIN {}

{if ($4 >= max) print $4, $5, $6, $7, $8}

END {}

then I call awk as follows

ls -l | awk -f files -v max=1024

this produces all the files. 
If I $max in the awk script, it just takes filed max.

I do not quite understand how variables are used as paramters in awk.

Any ideas gratefully received.

Thanks

Ken