Sponsored Content
Full Discussion: problem with variables
Top Forums Shell Programming and Scripting problem with variables Post 12160 by udi on Thursday 20th of December 2001 12:17:08 PM
Old 12-20-2001
Error problem with variables

hi all ,

i wanted to know if someone knows how can i use
a variable inside another variable


e.g.

#!/bin/csh
foreach test(1 2 3)
set sta_$test = "2"

##now its the problem i want to echo the new var
#$sta_$test , each time with anothe num ($test = 1 , 2 etc...)

echo $sta_$test
end

does anyone has an idea ??

thanks a lot

udi
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem in assigning values to variables

Hi, I have some problem in assigning values to variables: This is what Iam literally doing: i=0 input=test temp$i = $input In the sense, I try to assign the value in the variable input (ie., test) to another variable temp0 (since i is assigned 0, temp$i is temp0). Seems simple, but I get... (3 Replies)
Discussion started by: mohanprabu
3 Replies

2. Solaris

problem with environment variables

hi , i have a problem in setting value of $TERM variable in solaris while installing the SUN SPARCT1 simulation environment on ma pc so some one plkease guide me i have attached a snapshot of my error below thankew (1 Reply)
Discussion started by: Naughtydj
1 Replies

3. UNIX for Advanced & Expert Users

Problem in script when using variables

The AppName may be TCS/HCL/SCB. For All the above 3 i ill have exported TCSDIR/HCLDIR/SCBDIR in .profile with some path. i'm cnstruct the path in script and trying to cd $VARIABLE, it shows "not found". Any solution for this....? > AppName="TCS" > echo $AppName TCS >... (4 Replies)
Discussion started by: palsevlohit_123
4 Replies

4. Shell Programming and Scripting

Problem with variables in awk

Hi, I've a problem with wariables in awk. My example: $ cat test.txt 12|aaaa 13|bbbb 012|cccc 0123|dddd $ cat test.awk $1 == var {print $0} $ cat test.sh /usr/xpg4/bin/awk -F"|" -v var="012" -f test.awk test.txt (5 Replies)
Discussion started by: apresa
5 Replies

5. Shell Programming and Scripting

Sed with variables problem

I am writing a script with a sed call that needs to use a variable and still have quotations be present in the substitution. Example: sed -i "s/Replacable.\+$/Replaced="root@$VAR"/g" this outputs: where $VAR = place Replaced=root@place and i need Replaced="root@place" ... (2 Replies)
Discussion started by: mcdef
2 Replies

6. Shell Programming and Scripting

Problem combining two variables into one

Hello, I have a problem combining two variables into one. I did the following: in my env variables i had set PATH_DESTINATION_1=/root/path_one PATH_DESTINATION_2=/root/path_two #!/usr/bin/ksh count=1 count_path=2 while do (3 Replies)
Discussion started by: Eraser
3 Replies

7. Shell Programming and Scripting

concatenate variables problem

Hello, I have a tricky problem: I have a $file with a variable number of occurrences of "ORA-" (in this case two) .......... EXP-00008: ORACLE error 3113 encountered ORA-03113: end-of-file on communication channel EXP-00056: ORACLE error 1403 encountered ORA-01403: no data found... (9 Replies)
Discussion started by: Laurentiu
9 Replies

8. Shell Programming and Scripting

Problem with positional variables in BASH

Hello, my problem is simple & I searched a lot but I couldn't find anything about it: Basically I'd like to pass $i to a variable, $i being the positional variable; but it is unknown in the beginning so I can't do it like eg. myvar=$3, it HAS to be the "i".. First, I tried myvar=$($i) ... (8 Replies)
Discussion started by: timmyyyyy
8 Replies

9. Shell Programming and Scripting

Problem using iSQL and variables

I have searched the forums and other sites and cannot come with the applicable approach for what I am trying to do. I am trying to setup a cron job that executes this script. The script uses iSQL - which is connecting ok - to then query a field and then assign that field to a variable to do an If... (4 Replies)
Discussion started by: courtneyjh
4 Replies

10. Shell Programming and Scripting

Problem with variables in sed

Hello! I have a problem to insert variables with sed... And I can't find the solution. :confused: I would like to display one/few line(s) between 2 values. This line works well sed -n '/Dec 12 10:42/,/Dec 12 10:47/p' Thoses lines with variables doesn't work and I don't find the... (2 Replies)
Discussion started by: Castelior
2 Replies
while(n)						       Tcl Built-In Commands							  while(n)

__________________________________________________________________________________________________________________________________________________

NAME
while - Execute script repeatedly as long as a condition is met SYNOPSIS
while test body _________________________________________________________________ DESCRIPTION
The while command evaluates test as an expression (in the same way that expr evaluates its argument). The value of the expression must a proper boolean value; if it is a true value then body is executed by passing it to the Tcl interpreter. Once body has been executed then test is evaluated again, and the process repeats until eventually test evaluates to a false boolean value. Continue commands may be exe- cuted inside body to terminate the current iteration of the loop, and break commands may be executed inside body to cause immediate termi- nation of the while command. The while command always returns an empty string. Note: test should almost always be enclosed in braces. If not, variable substitutions will be made before the while command starts execut- ing, which means that variable changes made by the loop body will not be considered in the expression. This is likely to result in an infinite loop. If test is enclosed in braces, variable substitutions are delayed until the expression is evaluated (before each loop iter- ation), so changes in the variables will be visible. For an example, try the following script with and without the braces around $x<10: set x 0 while {$x<10} { puts "x is $x" incr x } SEE ALSO
break(n), continue(n), for(n), foreach(n) KEYWORDS
boolean value, loop, test, while Tcl while(n)
All times are GMT -4. The time now is 05:04 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy