home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.shell
- Path: sparky!uunet!caen!destroyer!ubc-cs!dhami
- From: dhami@cs.ubc.ca (Mandeep S Dhami)
- Subject: Re: Setting variables in Bourne Shell
- Message-ID: <1992Sep9.171034.17588@cs.ubc.ca>
- Keywords: bourne shell
- Sender: usenet@cs.ubc.ca (Usenet News)
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- References: <1992Sep9.154816.24978@casey.uucp>
- Date: Wed, 9 Sep 92 17:10:34 GMT
- Lines: 35
-
- kevinc@casey.uucp (Kevin C. Castner) writes:
-
- ># VARLIST is really set by a shell process
- >VARLIST="3 4"
-
- >for i in `cat ./test.db`
- >do
- > for j in `echo $VARLIST`
- > do
- > P${j}=`echo $i | cut -f ${j} -d ':'`
- ---> ^^^^
- > done
-
- > echo "P1:${P1}, P2:${P2}"
-
- >done
-
-
- Use eval. You can not assign to $variable, but you may eval
- such a string. To give you an example:
- # X=A
- # Y=B
- # $X=$Y
- A=B: not found # Same problem as yours,
- # eval $X=$Y # The Solution
- # echo $A
- B
-
-
- Mandeep
- __________________________________________________________________
- "I'm very brave generally," he went on in a low voice:
- "only to-day I happen to have a headache."
- -- Lewis Carroll
- __________________________________________________________________
-