On Sunday, May 26, 2002, at 09:53  PM, Schuessler, Robert BTB TKY wrote:

> Hello,
>
> I want to use grep to get a list of files into @files.  Here's what it 
> looks
> like now:
>
> $sender = "CHAS";
> $asofdate = "20020401";
>
> @files = `grep -sl $sender /home/data/*`;
> print @files;
>
>
>
> This gets all the files that contain CHAS, but what I really want is all 
> the
> files that contain CHAS and $asofdate and SETTLED.
>
> These unix commands work to get the correct subset of files (I'm using 
> ksh):
>
> grep -sl \<basis\>SETTLED\<\/basis\> $( grep -l CHAS $(grep -l
> \<asOfDate\>20020401\<\/asOfDate\> /home/data/*))
> grep -sl $bic /home/data/* | xargs grep -l \<basis\>SETTLED\<\/basis\> |
> xargs grep -l \<asOfDate\>$asofdate\<\/asOfDate\>
>
>
> If I try the first of these between the backticks in the perl script, I 
> get
> a sh error because it doesn't understand the ksh $() syntax.

i am not sure, but i would guess you have to escape the $ if you want it 
to go the shell without perl trying to interpolate it.

> If I try the second, I get this error:
> sh: syntax error at line 1: `|' unexpected

same with the pipe thingie.

>
> Can somebody suggest an easy way to call either of the above commands or 
> to
> emulate them with a perl command?  (For the moment, I've put them into a 
> ksh
> script and am calling the script, but I would like the perl script to be
> self-contained.)
>
>
> Thanks for your advice,
> Robert
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to