Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 27 Jan 1995 20:47:58 -0800 (PST)
From:      Morgan Davis <root@io.cts.com>
To:        roberto@blaise.ibp.fr (Ollivier ROBERT)
Cc:        dgy@seagull.rtd.com, freebsd-hackers@freefall.cdrom.com
Subject:   Re: shell trick?
Message-ID:  <199501280448.UAA07123@io.cts.com>
In-Reply-To: <9501271934.AA17198@blaise.ibp.fr> from "Ollivier ROBERT" at Jan 27, 95 08:34:11 pm

next in thread | previous in thread | raw e-mail | index | archive | help
Ollivier ROBERT writes:
> 
> >     How can I, in a shell script, read lines from a file, expand any
> > environment variables referenced therein and write results to another
> > file?
> 
> This not a real answer but you should really do this kind of things
> in perl... Its build-in eval function is great for this.

You could also do this with (ba)sh's eval statement.  Something like
this:

	read line < fromfile
	eval var=$line

This is only good for grabbing input from the first line of text in a
file.  You could use sed to extract other lines in a similar manner.

The variable var would hold the evaluated results from whatever was
read into the line variable.

Use echo to write the expanded stuff into other files (using > and >>
as needed).



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199501280448.UAA07123>