Matthew Woehlke wrote:
> $ sed -e '5d' -e '/FOO/d' -e '5,7d' myfile > mynewfile
> 
> Note that redirecting output to an input file is not recommended (you 
> might end up truncating the file, for example).

You almost certainly would.

> If you need to replace the file, it is best to write to a temporary
> file and use e.g. 'mv mynewfile myfile' when you are done.

Check out the newish sed option --in-place.  It does what you want.

  $ sed --in-place $SEDCOMMAND $SOMEFILE

This is available in sed version 4 and later.

Bob


_______________________________________________
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash

Reply via email to