It is currently Tue, 17 May 2022 18:53:05 GMT



 
Author Message
 double substitution (expansion)

I need to write a shell script with something like

set x1 = "something 1"
set x2 = "something 2"
.....................
set xN = "something N"

and later I need

foreach M (1 .......... N)
set y = x$M             (M being in the 1-N range)

how can I use y; I tried $y but this does not seem to work

Thanks for any suggestion

Francesco Mencaraglia - IROE - Via Panciatichi 64 - 50127 Firenze - Italy

me...@iroe.iroe.fi.cnr.it
me...@moloch.iroe.fi.cnr.it



 Sat, 08 May 1999 03:00:00 GMT   
 double substitution (expansion)

Dr Francesco Mencaraglia (me...@iroe.iroe.fi.cnr.it) wrote:
: I need to write a shell script with something like

: set x1 = "something 1"
: set x2 = "something 2"
: .....................
: set xN = "something N"

: and later I need

: foreach M (1 .......... N)
: set y = x$M           (M being in the 1-N range)

try:
eval  y=\"\$x$M\"

andru



 Sat, 08 May 1999 03:00:00 GMT   
 double substitution (expansion)

In article <56t449$...@nuke.csu.net>, luv...@andru.sonoma.edu (Andru

 > Dr Francesco Mencaraglia (me...@iroe.iroe.fi.cnr.it) wrote:
 > : I need to write a shell script with something like
 >
 > : set x1 = "something 1"
 > : set x2 = "something 2"
 > : .....................
 > : set xN = "something N"
 >
 > : and later I need
 >
 > : foreach M (1 .......... N)
 > : set y = x$M           (M being in the 1-N range)
 >
 > try:
 > eval  y=\"\$x$M\"
 >
 >
 > andru

Hi,
If, as your example suggests, you are using sequentially numbered
variables, you might as well try an array.
Just a thought.

Eric.



 Sun, 16 May 1999 03:00:00 GMT   
 double substitution (expansion)

Eric van der Meer wrote:

Try eval, you can double parse with it!!!



 Sun, 16 May 1999 03:00:00 GMT   
 
   [ 4 post ] 

Similar Threads

1. shell variables/command substitution/expansion

2. Double Variable Substitution

3. double quote variable expansion

4. double quoting in command substitution

5. How to do double substitution in bash ?

6. Double expansion in csh

7. double substitution in csh

8. HELP! Double variable expansion question

9. Command Substitution within Parameter Substitution?

10. HELP:bash: making tilde expansion after command expansion...


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software