Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!wuarchive!udel!rochester!kodak!ispd-newsserver!weimer From: weimer@ssd.kodak.com (Gary Weimer) Newsgroups: comp.unix.questions Subject: Re: batch file Message-ID: <1990Dec3.145338.6477@ssd.kodak.com> Date: 3 Dec 90 14:53:38 GMT References: <1990Dec2.211810.2302@iesd.auc.dk> Sender: news@ssd.kodak.com Organization: Eastman Kodak Lines: 22 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 You don't say why it doesn't work, but I would guess that it will work for one file, but not more than one. With more than one file, it will use the first file name for the file to search and the second file name for the string to search for. It might work if you called the program using quotes: "file1 file2 file3" string However, if this is all your shell is doing, it would be easier just to say: grep string file1 file2 file3