Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!olivea!uunet!convex!felps From: felps@convex.com (Robert Felps) Newsgroups: comp.unix.shell Subject: Re: Passing a var thru a file Message-ID: Date: 19 Jun 91 01:33:10 GMT References: <1991Jun18.153222.20836@cid.aes.doe.CA> Sender: usenet@convex.com (news access account) Distribution: na Organization: CONVEX Computer Corporation, Richardson, Tx., USA Lines: 43 Nntp-Posting-Host: mikey.convex.com In <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 I would assume you'll get plenty answers like, var=`cat file` eval echo $var but you might as well speed up the script too, var=`< file` eval echo $var or better yet, read var < file eval echo $var unfortunately, these only work in the Korn shell and the last one also works in later versions of the shell (>SVR2). Hope this helps, Robert Felps I do not speak for felps@convex.com Convex Computer Corp Convex and I seldom Product Specialist 3000 Waterview Parkway speak for myself. Tech. Assistant Ctr Richardson, Tx. 75080 VMS? What's that? 1(800) 952-0379