Subject: Re: Single user mode: ed(1) or bust
To: None <netbsd-users@netbsd.org>
From: Jukka Salmi <j+nbsd@2007.salmi.ch>
List: netbsd-users
Date: 05/05/2007 12:25:34
Lasse Hiller=F8e Petersen --> netbsd-users (2007-05-05 08:58:49 +0200):
> Of course, poor man's cat can be used to read from the console, and that's
> what I have used so far, retyping rather than really editing - but I am
> curious whether anyone has bothered to figure out a way to use only shell
> (and only a single process) to fix a few lines in an existing file?

E.g. like this:

$ cat in
a line
another line
you want to change lines from here...
=2E..to here
next line
some more lines

$ while read l; do case "$l" in *'from here'*) break;; esac; echo $l; done =
<in >out
$ echo 'add this' >>out
$ echo 'add that' >>out
$ o=3D; while read l; do [ "$o" ] && echo $l; case "$l" in *'to here'*) o=
=3Dy;; esac; done <in >>out

$ cat out
a line
another line
add this
add that
next line
some more lines


Cheers, Jukka

--=20
bashian roulette:
$ ((RANDOM%6)) || rm -rf ~