bourne shell query

William R. Pringle wrp at PRC.Unisys.COM
Sat Sep 1 13:11:32 AEST 1990


In article <1209 at wrs.wrs.com> roger at kymijoki.wrs.com (Roger Rohrbach) writes:
>fred at 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!



More information about the Comp.unix.shell mailing list