🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.shell
Article #985

Re: bourne shell query

#985
From: andrew.d.hay
Date: Fri, 31 Aug 1990 12:06
35 lines
1805 bytes
In article <26DC6447.15922@maccs.dcss.mcmaster.ca>, fred@maccs.dcss.mcmaster.ca (Fred Whiteside) writes:
[]
"								     what
" it should do is set the variable files to be the names of those
" articles in comp.std.c whose name (article number) is greater than or
" equal to the numeric value of the scripts first argument.
[]
" 
" #!/bin/sh
" 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

how about:
#!/bin/sh
cd /usr/spool/news/comp/std/c
echo "Should ignore files with name < $1 (formerly $zots)"
for TMP in `echo * | grep -v '[a-zA-Z]'`; do if [ "$TMP" -ge $1 ]; then echo "$TMP"; fi; done

or, if you -need- to create a variable:
files=`ls -rt | grep -v '[a-zA-Z]' | while read TMP; do if [ "$TMP" -ge $1 ]; then echo "$TMP"; fi; done`
echo $files

these should also be much faster, as it relies more on shell builtins.

i'm not familiar with awk (shame on me!), but i don't see why you need
it for this...

-- 
Andrew Hay		+------------------------------------------------------+
Ragged Individualist	| 	You just have _N_O idea!  It's the difference    |
AT&T-BL Ward Hill MA	|	between _S_H_O_O_T_I_N_G a bullet and _T_H_R_O_W_I_N_G it!     |
a.d.hay@att.com		+------------------------------------------------------+
Technical Details
Message-ID: <1990Aug31.120616.6984@cbnews.att.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!att!cbnews!mvadh
References: <26DC6447.15922@maccs.dcss.mcmaster.ca>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!att!cbnews!mvadh
From: mvadh@cbnews.att.com (andrew.d.hay)
Newsgroups: comp.unix.shell
Subject: Re: bourne shell query
Summary: news filefinder script tweak
Message-ID: <1990Aug31.120616.6984@cbnews.att.com>
Date: 31 Aug 90 12:06:16 GMT
References: <26DC6447.15922@maccs.dcss.mcmaster.ca>
Distribution: na
Organization: AT&T Bell Laboratories
Lines: 35