From owner-freebsd-hackers Fri Jan 27 20:56:28 1995 Return-Path: hackers-owner Received: (from root@localhost) by freefall.cdrom.com (8.6.9/8.6.6) id UAA06513 for hackers-outgoing; Fri, 27 Jan 1995 20:56:28 -0800 Received: from vmbb.cts.com (vmbb.cts.com [192.188.72.18]) by freefall.cdrom.com (8.6.9/8.6.6) with SMTP id UAA06507 for ; Fri, 27 Jan 1995 20:56:26 -0800 Received: from io.cts.com by vmbb.cts.com with smtp (Smail3.1.28.1 #9) id m0rY5CV-0000HaC; Fri, 27 Jan 95 20:55 PST Received: (from root@localhost) by io.cts.com (8.6.9/8.6.9) id UAA07123; Fri, 27 Jan 1995 20:48:00 -0800 From: Morgan Davis Message-Id: <199501280448.UAA07123@io.cts.com> Subject: Re: shell trick? To: roberto@blaise.ibp.fr (Ollivier ROBERT) Date: Fri, 27 Jan 1995 20:47:58 -0800 (PST) Cc: dgy@seagull.rtd.com, freebsd-hackers@freefall.cdrom.com In-Reply-To: <9501271934.AA17198@blaise.ibp.fr> from "Ollivier ROBERT" at Jan 27, 95 08:34:11 pm X-Mailer: ELM [version 2.4 PL23] Content-Type: text Content-Length: 752 Sender: hackers-owner@FreeBSD.org Precedence: bulk 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).