Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 10 Jul 1997 09:08:24 -0400
From:      Dennis Rockwell <dennis@bbn.com>
To:        Simon N Atkin <simat@enta.net>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: SED remove from live file 
Message-ID:  <199707101305.JAA01957@po3.bbn.com>
In-Reply-To: Message from Simon N Atkin <simat@enta.net>  <33C3F7B9.5636@enta.net> .

next in thread | previous in thread | raw e-mail | index | archive | help
On 9 Jul, Simon N Atkin wrote:

> Anyone know how to remove a certain string from a file
> without having the create a tmp file.
> 
> i.e sed "s/\.//g" simat.dat strip all . 's from simat.dat

Sheesh, you guys.  I must've started with UNIX too long ago,
back when "ed" was useful.  The simplest way is *not* to use
sed, but use "ed -" instead:

echo '1,$s/\.//g\
w\
q' | ed - simat.dat

This quoting works for tcsh; YMMV.

Yes, yes, ed will create a temp file, but not in the current
directory, and it takes care of deleting it for you.  The
renaming suggestions momentarily suck up twice as much space
in the current directory.

Why do you want to avoid the temp file?  Is "simat.dat"
waaay too big or something?  Or were you avoiding the
cleanup?

Dennis Rockwell                 dennis@bbn.com
Bolt Beranek & Newman
Systems & Technologies          +1-617-873-5745
Cambridge, MA                   +1-617-873-6091 (Fax)




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