set variable with another variable? c shell


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting set variable with another variable? c shell
# 1  
Old 02-23-2008
set variable with another variable? c shell

okay, this shouldn't be difficult but I can't figure it out. How can I set a variable with another variable. I have the following:

foreach pe ($dir $sp)

set tpe = `echo $pe | grep M`
if ($tpe == M) then

set ${$pe} = M <--- This doesn't work

else
endif

end

In this case what I want is to reset the varialbe $dir within the if statement.

Any ideas?
# 2  
Old 02-23-2008
Wrong:

set ${$pe} = M

Good:
set pe = M
# 3  
Old 02-23-2008
Looks like I was just over thinking the issue. Thanks. Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

set variable with square brackets in c shell!

Hi Guys, I want to set a variable which happend to have square brackets in them. I tried multiple ways that is by escaping it with quotes (both single and double ) but it didn't help. All I want is: set x = slicearray.slice\.post My failed attempts were: set x = "slicearray.slice\.post"... (3 Replies)
Discussion started by: dixits
3 Replies

2. Shell Programming and Scripting

Set shell variable from command

shell script has a command inside back quotes in method update_TABLE I need to store the count of number of Rows updated and store it in shell script variable "num" num = 0; Update_TABLE Update_TABLE() { `echo " set verify off feedback off echo off pagesize 0 head off... (4 Replies)
Discussion started by: finder255
4 Replies

3. Shell Programming and Scripting

how to set/get shell env variable in python script

greetings, i have a sh script that calls a python script. the sh script sets an env variable BIN: export BIN=bin64i need to get that BIN variable's value and use it within this python script. anyone know how to do this? thanx in advance. (5 Replies)
Discussion started by: crimso
5 Replies

4. Shell Programming and Scripting

Not able to store command inside a shell variable, and run the variable

Hi, I am trying to do the following thing var='date' $var Above command substitutes date for and in turn runs the date command and i am getting the todays date value. I am trying to do the same thing as following, but facing some problems, unique_host_pro="sed -e ' /#/d'... (3 Replies)
Discussion started by: gvinayagam
3 Replies

5. Shell Programming and Scripting

assign awk's variable to shell script's variable?

Dear All, we have a command output which looks like : Total 200 queues in 30000 Kbytes and we're going to get "200" and "30000" for further process. currently, i'm using : numA=echo $OUTPUT | awk '{print $2}' numB=echo $OUTPUT | awk '{print $5}' my question is : can I use just one... (4 Replies)
Discussion started by: tiger2000
4 Replies

6. Shell Programming and Scripting

Set/Export Env Vars from with Shell Script With Input Variable

I have a shell script I want to run that will set environment variables based on the value of an input variable submitted when the shell script is called. For example: $ mgenv.sh prod This would set environment variables for prod $ mgenv.sh test This would set environment variables... (1 Reply)
Discussion started by: brtaylor73
1 Replies

7. Shell Programming and Scripting

How to make nawk to set a shell variable

Below is the content of the file I am parsing bash-2.03$ cat rakesh cpio: Cannot write "reloc/lib/gcc-lib/i386-pc-solaris2.7/2.95.2/gmon.o", errno 28, No space left on device cpio: Cannot write "reloc/lib/gcc-lib/i386-pc-solaris2.7/2.95.2/include/README", errno 28, No space left on device... (1 Reply)
Discussion started by: rakeshou
1 Replies

8. Shell Programming and Scripting

problem in getting the path of environment variable set in bashrc in my shell script

hi all i have joined new to the group. i have set an variable in my bashrc file. .bashrc PROGHOME=/home/braf/braf/prog export PROGHOME but while using it in my shell script its path is not taken and i had to explicitly give the export command to set the path. in my script... (8 Replies)
Discussion started by: krithika
8 Replies

9. UNIX for Dummies Questions & Answers

Export command giving Variable Name vs the Value set for the Variable

I'm having an issue when I export within my program. I'm getting the variable name, not the variable value. I have a configuration file (config.txt) that has the values of the variables set as so: set -a export ARCHIVEPOSourceDir="/interfaces/po/log /interfaces/po/data" export... (2 Replies)
Discussion started by: ParNone
2 Replies

10. Shell Programming and Scripting

Set Path variable in c shell

I set my path environment variable in c shell, using the syntax below setenv PATH "${PATH}:/usr/local:/usr/local/bin" and placed this in $HOME/.login $HOME/.cshrc and /etc/.login /etc/.cshrc but when I issued echo $PATH or set command the output does not reflect changes made to... (5 Replies)
Discussion started by: hassan2
5 Replies
Login or Register to Ask a Question