*BSD News Article 24593


Return to BSD News archive

Newsgroups: comp.unix.bsd
Path: sserve!newshost.anu.edu.au!munnari.oz.au!uniwa!harbinger.cc.monash.edu.au!msuinfo!agate!howland.reston.ans.net!spool.mu.edu!nigel.msen.com!heifetz!mrdog!dhl
From: dhl@mrdog.msl.com (Donald H. Locker)
Subject: Re: command output substitution in sh script
Message-ID: <CHD5o8.2on@mrdog.msl.com>
Organization: Chelsea MSL, Inc.   Chelsea, MI   USA
References: <2dgje8$grv@usenet.INS.CWRU.Edu> <2dglq2$kau@usenet.ins.cwru.edu>
Date: Wed, 1 Dec 1993 15:57:43 GMT
Lines: 28

In article <2dglq2$kau@usenet.ins.cwru.edu>,
Donna A. Lilly <bx970@po.cwru.edu> wrote:
>
>In a previous article, bx970@cleveland.Freenet.Edu (Donna A. Lilly) says:
>
>>I want to process files that start with someprefix a period followed by two
>>digits (just for an example).  I couldn't get this to work in the sh syntax.
>>
>>in csh:
>>

check out: foreach file (someprefix.[0-9][0-9])

>>if (`cat $file | egrep 'someprefix\.[0-9][0-9]$' | wc -c` > 13) then
>      ^^^
>Oops!  I meant to say `echo $file ...  not cat (I wanted to test the
>filename not file contents).
>Anyhow, anyone know how this is done in sh scripts?
>

for file in someprefix.[0-9][0-9]
do whatever_processing_is_required
done

-- 
Donald.                      |  Coffee, Donuts, Scotch and Maalox(TM)
Opinions? sure they're mine. |  The sys admins' four major food groups.
Who else would claim 'em?    |  (apologies to _Duffy_)