Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!cbnews!cbnewsl!bonnie!rbr From: rbr@bonnie.ATT.COM (228-4197,ATTT) Newsgroups: comp.unix.shell Subject: Re: Passing a var thru a file Message-ID: <1991Jun18.173451.20361@cbnewsl.att.com> Date: 18 Jun 91 17:34:51 GMT References: <1991Jun18.153222.20836@cid.aes.doe.CA> Sender: news@cbnewsl.att.com (NetNews Administrator) Reply-To: rbr@bonnie.ATT.COM (Bob Rager) Distribution: na Organization: AT&T Bell Laboratories Lines: 28 In article <1991Jun18.153222.20836@cid.aes.doe.CA> afsipmh@cidsv01.cid.aes.doe.CA () writes: >Say i have a file that (just for the sake of this question) contains >just one word: >$ENVAR > >Say $ENVAR is an environmental variable > >What is it about the shell that prevents interpretation: > >#!/bin/sh >var=`cat file` >echo $var #gives (literally) $ENVAR >echo `echo $var` #also gives (literally) $ENVAR >-- >Pat Hertel Canadian Meteorological Centre >Analyst/Programmer 2121 N. Service Rd. >phertel@cmc.aes.doe.ca Dorval,Quebec >Environment Canada CANADA H9P1J3 The shell never sees $ENVAR as a variable, only a string of arbitrary characters. Try: var=`cat file` echo `eval $var` Bob Rager