From owner-freebsd-questions@FreeBSD.ORG Tue Apr 5 23:06:12 2005 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 656AF16A4CE for ; Tue, 5 Apr 2005 23:06:12 +0000 (GMT) Received: from mail.gmx.net (mail.gmx.de [213.165.64.20]) by mx1.FreeBSD.org (Postfix) with SMTP id 51D1543D39 for ; Tue, 5 Apr 2005 23:06:11 +0000 (GMT) (envelope-from m@MHoerich.de) Received: (qmail invoked by alias); 05 Apr 2005 23:06:09 -0000 Received: from pD9E582EF.dip.t-dialin.net (EHLO localhost) [217.229.130.239] by mail.gmx.net (mp029) with SMTP; 06 Apr 2005 01:06:09 +0200 X-Authenticated: #5114400 Date: Wed, 6 Apr 2005 01:06:06 +0200 From: Mario Hoerich To: Martin McCormick Message-ID: <20050405230605.GA93190@Pandora.MHoerich.de> References: <200504052028.j35KSU9S042813@dc.cis.okstate.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200504052028.j35KSU9S042813@dc.cis.okstate.edu> User-Agent: Mutt/1.4.2.1i X-Y-GMX-Trusted: 0 cc: freebsd-questions@freebsd.org Subject: Re: Bourn Shell Scripts that Produce Multiple Files X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Apr 2005 23:06:12 -0000 # Martin McCormick: > I wrote a Bourn Shell script which has a while loop in it that > reads a file line by line. The output of the script is supposed to go > to a file with a different name for each iteration of the loop. This > scheme is obviously a rotten idea because all the new files end up > created, but quite empty. If I take out the > $newfilename.txt > directive, I get the proper output at stdout so the only problem is > with changing the file name in the middle of the game several times. This sounds a bit like a truncation issue. If you do something like command1 > bar # some code command2 > bar then the second redirect will truncate the file to 0 bytes before redirecting the output from command2 into it. Try using >> instead of >, as it appends to the file. If this doesn't help, please post the script (or a simplified version thereof). We're not clairvoyant, you know... :) HTH, Mario