![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Passing global variable to a function which is called by another function | sars | Shell Programming and Scripting | 4 | 06-30-2008 08:39 AM |
| Passing a unix variable value to a Plsql function | cobroraj | UNIX for Advanced & Expert Users | 1 | 10-30-2007 03:59 AM |
| passing variable to function | Knotty | UNIX for Dummies Questions & Answers | 4 | 04-04-2007 09:49 PM |
| ksh: A part of variable A's name is inside of variable B, how to update A? | pa3be | Shell Programming and Scripting | 4 | 03-30-2005 08:29 AM |
| Passing a variable name to be created within a function | 435 Gavea | Shell Programming and Scripting | 2 | 02-04-2004 12:20 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
I would like to know how to pass a variable inside a variable to a function.
sample code below -------------- for x in 1 9 do check_null $C$x ##call function to check if the value is null if [ $? -eq 1 ] then echo "line number:$var_cnt, message: field is not null" fi done -------------- C1 has a value, as does C9 I need to pass values stored in C1 and C9 to the function Any help would be highly appreciated. Thanks |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Ah, you want the shell to parse "$C$x" as "$C1" but instead it is doing "$C" + "$x". So, you need to force it to evaluate $x first.
Code:
# C1=abc # x=1 # echo $C$x 1 # eval echo \$C$x abc |
|
#3
|
|||
|
|||
|
Yes, I believe thats the way to do it, but how to call the function using the above ? (BTW, thanks for your post)
|
|||
| Google The UNIX and Linux Forums |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|