dynamic string searching for grep

hi my code is something like

   count=0
     echo "oracle TABLESPACE NAME  nd TARGET"

      while [ loop condition ]
      do
               count=`expr $count + 1`

             (1)     tts_space_name$count=`echo $tts | cut -d "," -f$count`

       (2) target$count=grep $(tts_space_name$count) cfg.txt | cut -d'=' -f2
      done

in line (1) value is getting assigned to tts_space_name$count , but den it is displaying error as no data found as shown
'

tts_space_name1=TBS_ADOX_EXTR3:  not found.

'

then in line (2) i want to give dynamic string to grep command , getting error as no error found ...

help in either case will be appreciated .... :slight_smile:
plz help.

try something like this..

for i in {1..5}; do
eval var$i='$i'
done

for i in {1..5}; do
eval echo "$`echo "var$i"`"
done

1
2
3
4
5

1) pls use code tags for your code & data
2) post the result of echo $tts and echo $tts | cut -d "," -f$count
3) grep will use variables, but you did not define/assign one due to an error.