Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!cme!rrdstrad.nist.gov!chench From: chench@rrdstrad.nist.gov (Frank Chen) Newsgroups: comp.unix.questions Subject: Re: batch file Message-ID: <8607@durer.cme.nist.gov> Date: 5 Dec 90 20:55:35 GMT References: <1990Dec2.211810.2302@iesd.auc.dk> Sender: news@cme.nist.gov Organization: Reactor Research Division, NIST Lines: 32 In article <1990Dec2.211810.2302@iesd.auc.dk> claus@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@rrdstrad.nist.gov chen@enh.nist.gov chen@nbsenh.bitnet