Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

neowin

macrumors newbie
Original poster
Jun 27, 2011
19
0
Hi,

I am trying to display a variable's value in terminal of mac. But it is not happening.

This is the steps I do-

set var = 2
echo $var

This should display 2, but a empty line is shown.
I think I need to set some env variable.But i do not know the details. Please help.
 
Hi,

I am trying to display a variable's value in terminal of mac. But it is not happening.

This is the steps I do-

set var = 2
echo $var

This should display 2, but a empty line is shown.
I think I need to set some env variable.But i do not know the details. Please help.

Which shell is this?

If it is "bash"

then try this
var=2
echo $var.

If you are running "csh" then it would be
setenv var 2
echo $var

You title says "in UNIX" yes Mac OS is based on UNIX but UNIX is the name of an OS.. What you are typing commands into is a program called a shell. There are several shells you can use. Mac OS X ships with at least three shells and you get to pick with runs for each account
 
Yep got it. Thanks!

instead of
set var = 2
i did
var=2

This prints the value.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.