Append values before a string

hi all,
i have variables a and b with values, like
a="/var/tmp/new.sh /var/tmp/new2.sh"
b="/TEST"

how i need to append the value "/TEST" before the values for the variable "a" so that i get the output as

/TEST/var/tmp/new.sh /TEST/var/tmp/new2.sh

plz help me

Regards,
NG

Hi,
this should work:
a="/var/tmp/new.sh /var/tmp/new2.sh"
b="/TEST"
for i in $a; do
echo "$b$i"
done

Bye

If your first variable would contain only one value it would be a simple concatenation:

a="/my/content"
b="/additional"

c="${a}${b}"
print - "$c"

You might consider changing your variable $a to an array where each element contains exactly one value. You could use the above mechanism then:

a[1]="/my/content1"
a[2]="/my/content2"
a[3]="/my/content3"
a[4]="/my/content4"

b="/additional"
i=1

while [ $i -le ${#a[*]} ] ; do
     c="${b}${a[$i]}" ; print - "$c" # only display the changed value
     # a[$i]="${b}${a[$i]}"          # alternatively store it back to the array
     (( i += 1 ))
done

If you want to stick with your way of storage content use a for-loop to cycle through all the elements of your variable and add the additional content to every element one at a time:

a="/my/content1 /my/content2 /my/content3 /my/content4"
b="/additional"
i=""
newstring=""

for i in $a ; do
     c="${b}${i}" ; print - "$c"    # only display the changed value
     # newstring="${newstring}${c}" # alternatively concatenate to a new string
done

I hope this helps.

bakunin