Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 1 Feb 2002 15:22:07 -0800
From:      "Crist J. Clark" <cristjc@earthlink.net>
To:        Paul David Fardy <pdf@morgan.ucs.mun.ca>
Cc:        questions@FreeBSD.ORG, Eric Six <erics@sirsi.com>
Subject:   Re: Perl question...
Message-ID:  <20020201152207.C956@gohan.cjclark.org>
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
References:  <200202012054.g11KslkB001080@plato.ucs.mun.ca>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Feb 01, 2002 at 05:24:46PM -0330, Paul David Fardy wrote:
> Eric Six <erics@sirsi.com> 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" <cristjc@earthlink.net> 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




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