If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > pointers in SHELL

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-24-04, 12:27
amolbc amolbc is offline
Registered User
 
Join Date: Mar 2004
Posts: 7
Exclamation pointers in SHELL

#!/bin/bash

C1=a
C2=b
C3=c

for cnt in 1 2 3
do
var=C
var=$var$cnt
echo ????
done


this is the code i need in a script am at....what i want to print is
a
b
c

so this is like a pointer in C...how do i do this in my dear UNIX shell

please help....no, no need of Please and the like....we all are here to help each other...o..o i think u all are here to help me ;-)
Reply With Quote
  #2 (permalink)  
Old 03-24-04, 13:38
aigles aigles is offline
Registered User
 
Join Date: Jan 2004
Location: Bordeaux, France
Posts: 319
You must use the eval command
Code:
#!/usr/bash
C1=a
C2=b
C3=c
for cnt in 1 2 3
do
   var=C$cnt
   eval value=\$$var
   echo $value
   # or
   eval value=\$C$cnt
   echo $value
done
__________________
Jean-Pierre.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On