Find the answer to your Linux question:
Results 1 to 2 of 2
#shell script cd1 = ENGR77 #environment variable i=1 # local var k="cd$i" echo "$k" Hi every one ... I wan't to print the value of 'k' as ENGR77.but i am ...
  1. #1
    Just Joined!
    Join Date
    Dec 2008
    Posts
    4

    double variable substitution

    #shell script

    cd1 = ENGR77 #environment variable
    i=1 # local var

    k="cd$i"
    echo "$k"

    Hi every one ... I wan't to print the value of 'k' as ENGR77.but i am getting the o/p
    of 'k' as 'cd1'. the problem here is with the double variable substitution.
    i have tried

    eval echo $k
    echo k=${cd$i}

    here the 'cd1' is a global variable and 'i' local variable.i am using bash shell.

  2. #2
    Linux Newbie
    Join Date
    Feb 2009
    Posts
    99
    try
    cd1=ENGR77
    replace
    cd1 = ENGR77 #environment variable

    notice space not needed with "="

    and

    ooo=$"cd$1" means ooo=ENGR77

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...