[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: grep not recognizing a variable when searching

From: Stepan Kasal
Subject: Re: grep not recognizing a variable when searching
Date: Wed, 7 Jul 2004 11:28:40 +0200
User-agent: Mutt/1.4.1i


On Mon, Jul 05, 2004 at 11:16:40AM -0300, McCracken, Mark wrote:
> I have defined a variable and then I am trying to search for the variable in
> a file.
> set abc = `cat file`
> set i = 1
> grep $abc[$i] file2
> A status of 1 is returned.
> The above works for me on UNIX, is there another way I should be doing this
> for Cygwin?

you seem tdo use a variant of csh on UNIX, perhaps `tcsh'.
On cygwin, you probably use another shell, probably the default: `bash'.

(Shell is the program which interprets your commands and executes them, like
command.com on DOS.)

You either have to execute tcsh on Cygwin, or you should change the commands.
In Bourne-derived shells, including `bash', you assign variables this way:

abc="a b c"

(no spaces, no `set' keyword).  If you want to learn more about shell scripting,
try any good Unix book, or Advanced Bash Scripting Guide,

        Stepan Kasal

reply via email to

[Prev in Thread] Current Thread [Next in Thread]