*BSD News Article 24568


Return to BSD News archive

Path: sserve!newshost.anu.edu.au!munnari.oz.au!constellation!paladin.american.edu!howland.reston.ans.net!usenet.ins.cwru.edu!cleveland.Freenet.Edu!bx970
From: bx970@cleveland.Freenet.Edu (Donna A. Lilly)
Newsgroups: comp.unix.bsd
Subject: command output substitution in sh script
Date: 30 Nov 1993 23:02:31 GMT
Organization: Case Western Reserve University, Cleveland, OH
Lines: 19
Message-ID: <2dgje8$grv@usenet.INS.CWRU.Edu>
Reply-To: bx970@po.cwru.edu (Donna Lilly)
NNTP-Posting-Host: nextsun.ins.cwru.edu

Earlier I asked about testing if a file exists csh scripts and I was
convinced to use sh for programming.  One problem I have is with
substitution of a commands output and testing the resulting value in the sh
syntax.  E.g.

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:

if (`cat $file | egrep 'someprefix\.[0-9][0-9]$' | wc -c` > 13) then

in sh:

?  

-- 
        Donna Lilly
        Cleveland, OH