Assigning values to variables

Assigning values to variables

Post by Davi » Mon, 28 Jul 2003 21:30:03



Hi there,

Why can't I assign a value to a variable directly at my terminal like so?

titanic:~/unix:76 % my_bin=/users/steven/bin
my_bin=/users/steven/bin: Command not found.

Thanks!

 
 
 

Assigning values to variables

Post by Rich » Mon, 28 Jul 2003 22:27:10


In infinite wisdom David answered:

Quote:> Hi there,

> Why can't I assign a value to a variable directly at my terminal like so?

> titanic:~/unix:76 % my_bin=/users/steven/bin
> my_bin=/users/steven/bin: Command not found.

Looks like you're login shell is csh. The syntax is bourne or
korn shell.

You need either switch to bourne or korn shell or use the syntax
for csh.

        whatever% my_bin=/users/steven/bin
        my_bin=/users/steven/bin: Command not found
        whatever% ksh
        $ my_bin=/users/steven/bin
        $ exit
        whatever% set my_bin=/users/steven/bin
        whatever% echo $my_bin
        /users/steven/bin
        whatever%

Then again, perhaps what you really want to do is add ~/bin
to your path variable?

Rich

Quote:> Thanks!


 
 
 

Assigning values to variables

Post by Sven Gohlk » Mon, 28 Jul 2003 22:26:24



> Why can't I assign a value to a variable directly at my terminal like so?

> titanic:~/unix:76 % my_bin=/users/steven/bin
> my_bin=/users/steven/bin: Command not found.

Because You are using a csh?

set my_bin=/users/steven/bin

should work in this case (or setenv if You want to export).
--
Best Regards
Sven

 
 
 

Assigning values to variables

Post by Chris Matter » Wed, 30 Jul 2003 00:14:33



> Hi there,

> Why can't I assign a value to a variable directly at my terminal like so?

> titanic:~/unix:76 % my_bin=/users/steven/bin
> my_bin=/users/steven/bin: Command not found.

> Thanks!

Because you are running csh or some variant and trying
to use Bourne shell syntax.

Try "set my_bin=/usrers/steven/bin".  Better yet,
quit using csh.

                  Chris Mattern

 
 
 

1. How to search for string and assign the value on next line to a variable

Here's kind of a goofy one...haven't figured out how (if) it is doable
by sed/awk yet, so I thought I'd give the brain trust here a looksee
and determine if there is a better way to handle this issue...

I have several large txt files that I need to search for a particular
string and assign the value on a subsequent line to a variable...so for
instance using this snippet:

---=[ OS Version (Version.Release.Modification.Fix)
]=--------------------
5.3.0.0

I want to be able to search the file for the string
"Version.Release.Modification.Fix"

and assign the variable OS_VER a value of 5.3.0.0

Thanks for any/all replies!

2. e2fs: bad magic number in superblock, help !!

3. Assigning an exit value to a Bourne shell variable?

4. bpfilter

5. Assigning a variable a value with the "time" command

6. looking for some files

7. Assigning a variable value in a script question.

8. X resources

9. assigning a value returned from a function to a variable

10. Help!How to assign a value to a variable in awk

11. Assigning a Value to Null Variables (sh)

12. assign a value in a variable in sh

13. assigning variables via variables