batch file

Frank Chen chench at rrdstrad.nist.gov
Thu Dec 6 07:55:35 AEST 1990


In article <1990Dec2.211810.2302 at iesd.auc.dk> claus at iesd.auc.dk (Claus S. 
Jensen) writes:
>   I am trying to make a batch file, that looks through
> a number of textfiles for a string. I've made up something
> like this, but it doesn't work. Can anybody tell me why
> this is, and perhaps if there is another way to do it.
> 
> 
> #!/bin/tcsh
> foreach file ($1)
> echo $file
> cat $file | grep $2
> end

When you use wild card for filename, "quote" the file name.
Example:
% ls .
doc1.txt      doc2.txt      doc3.txt
% script "*"  text                 /* This will give you correct result */

Using "script * text" will be translated by shell into "script doc1.txt 
doc2.txt doc3.txt text" Then you are actually search for the
 string "doc2.txt" in the file "doc1.txt"


----------------------------------------
Frank Chen              
NIST                        
Bldg. 235/E-151     
chench at rrdstrad.nist.gov
chen at enh.nist.gov
chen at nbsenh.bitnet



More information about the Comp.unix.questions mailing list