Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem: Assigning value to a variable. 1

Status
Not open for further replies.

dvsmas

Programmer
Jun 20, 2001
16
0
0
US
Hi,
I'm a novice to Unix, so please help me understand the correct syntax.
i've these steps in my K shell:

var=filename
"$var"=`echo "thereport"`

But the system is giving an error:
filename=thereport: not found

Why would nt this work?
What should I do to make it work?
I eventually have to use this step in a function and pass "var" into the function.
 
Take the quotes out from around $var

Depends what you're trying to do, you might want to post what you're trying to do and you might get a little more detailed answer :D

C
 
Oh, sorry... you asked why and I forgot to tell you; usually I make the reverse mistake.

The error you get says that, by the time the shell has expanded everything and is trying to figure out what to do with the command, it's past the point where it will consider the command to be a variable assignment. Instead, it goes looking for an executable named [tt]filename=thereport[/tt], which more than likely doesn't exist.

The [tt]eval[/tt] command says, "Ok, now that we've expanded everything and gotten a result, let's just pretend that we saw the result." That gets the shell to start over again in its considerations of what the command can mean.

Annoying, but necessary.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top