Article View: comp.unix.shell
Article #980Re: bourne shell query
From: William R. Pringle
Date: Sat, 01 Sep 1990 03:11
Date: Sat, 01 Sep 1990 03:11
29 lines
1335 bytes
1335 bytes
In article <1209@wrs.wrs.com> roger@kymijoki.wrs.com (Roger Rohrbach) writes:
>fred@maccs.dcss.mcmaster.ca (Fred Whiteside) writes:
>
>>cd /usr/spool/news/comp/std/c
>>zots=$1
>>echo "Should ignore files with name < $zots"
>>files=`ls -rt * |grep -v '.*[a-zA-Z].*' | awk $1 '>=' $zots {print}`
>>echo $files
>
>
(Followed by several variations on how to arrange quotes so that
a shell variable can get into an AWK program.)
I'm surprised no one mentioned the simple way:
awk '$1 >= MAX{print}' MAX=$zots -
The MAX=value sets the awk variable MAX to 'value', the dash is needed
to indicate using stdin. You could eliminate the grep by letting awk
do it for you:
awk '/^[0-9]*/{if ($1 >= MAX) print}' MAX=$zots -
No that we have probably confused the original poster beyond hope ...
Good luck!
Bill Pringle
The nice thing about Unix is that there are so many right answers!
Technical Details
Message-ID:
<14877@burdvax.PRC.Unisys.COM>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!udel!burdvax!wrpReferences:
<26DC6447.15922@maccs.dcss.mcmaster.ca> <1209@wrs.wrs.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!udel!burdvax!wrp From: wrp@PRC.Unisys.COM (William R. Pringle) Newsgroups: comp.unix.shell Subject: Re: bourne shell query Message-ID: <14877@burdvax.PRC.Unisys.COM> Date: 1 Sep 90 03:11:32 GMT References: <26DC6447.15922@maccs.dcss.mcmaster.ca> <1209@wrs.wrs.com> Organization: Unisys Corporation, Paoli Research Center; Paoli, PA Lines: 29