From owner-freebsd-questions Fri Feb 1 15:23: 2 2002 Delivered-To: freebsd-questions@freebsd.org Received: from scaup.prod.itd.earthlink.net (scaup.mail.pas.earthlink.net [207.217.120.49]) by hub.freebsd.org (Postfix) with ESMTP id 0B30B37B4E4 for ; Fri, 1 Feb 2002 15:22:46 -0800 (PST) Received: from user-2ivfo1m.dialup.mindspring.com ([165.247.224.54] helo=gohan.cjclark.org) by scaup.prod.itd.earthlink.net with esmtp (Exim 3.33 #1) id 16Wn0z-0001MT-00; Fri, 01 Feb 2002 15:22:43 -0800 Received: (from cjc@localhost) by gohan.cjclark.org (8.11.6/8.11.1) id g11NM8c01102; Fri, 1 Feb 2002 15:22:09 -0800 (PST) (envelope-from cjc) Date: Fri, 1 Feb 2002 15:22:07 -0800 From: "Crist J. Clark" To: Paul David Fardy Cc: questions@FreeBSD.ORG, Eric Six Subject: Re: Perl question... Message-ID: <20020201152207.C956@gohan.cjclark.org> Reply-To: cjclark@alum.mit.edu References: <200202012054.g11KslkB001080@plato.ucs.mun.ca> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <200202012054.g11KslkB001080@plato.ucs.mun.ca>; from pdf@morgan.ucs.mun.ca on Fri, Feb 01, 2002 at 05:24:46PM -0330 X-URL: http://people.freebsd.org/~cjc/ Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Fri, Feb 01, 2002 at 05:24:46PM -0330, Paul David Fardy wrote: > Eric Six wrote: > >> I have found ways to append lines to the file, but not to create a new > >> one at the very beginning. Also, any ideas on how to automate doing > >> this to all the files in each dir? > > "Crist J. Clark" wrote: > > ed(1) man. man ed. > > > > for FILE in $DIR; do > > ed $DIR/$FILE <<"EOF" > > 1i > > $TTL value > > . > > wq > > EOF > > done > > I've been using Perl so much, I've forgotten some of my shell rules. > I tested this code because I thought "$TTL" would result in the > expansion of an undefined variable TTL. In Perl, it _would_ be a > problem. In sh, it's fine. It is not expanded because I quoted "EOF" as the here-doc delimiter. If I had not, it would have been. > But I think I'll still add a few notes. > > > for FILE in $DIR; do > > ed $DIR/$FILE <<"EOF" > > This should, I think, be > > for file in *; do > ed $file <<"EOF" > > or > > for file in */*; do > ed $file <<"EOF" Correct, I meant to write, for FILE in $DIR/*; do ed $FILE <<"EOF" The first line was a typo. The second... guess I was typing too fast and not proof reading, sorry. -- Crist J. Clark | cjclark@alum.mit.edu | cjclark@jhu.edu http://people.freebsd.org/~cjc/ | cjc@freebsd.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message