batch file

Gary Weimer weimer at ssd.kodak.com
Tue Dec 4 01:53:38 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

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:

    <program> "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



More information about the Comp.unix.questions mailing list