Robert Btb Tky Schuessler wrote:
> 
> Hello,

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.
> If I try the second, I get this error:
> sh: syntax error at line 1: `|' unexpected
> 
> 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.)

Once you get the list of files do you want to modify their contents? 
Delete them?  Copy or move them to a different location?

If you just want to print out the list of files (all on one line):

perl
-lne'print($ARGV)&&close(ARGV)if/<basis>SETTLED<\/basis>/&&/CHAS/&&/<asOfDate>20020401<\/asOfDate>/'
/home/data/*



John
-- 
use Perl;
program
fulfillment

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

Reply via email to