Sed question

Gary Kline kline at thought.org
Sun Dec 21 10:06:24 UTC 2008


On Sun, 2008-12-21 at 07:42 +0200, Giorgos Keramidas wrote:
> On Sat, 20 Dec 2008 21:34:10 -0800, Gary Kline <kline at thought.org> wrote:
> > how can i delete, say, lines 8,9,and 10 from 200 files
> > using sed?  Is it
> >
> > sed '8,10d'< file> newfile
> > or is there a better way?
> 
> Use in-place editing:
> 
>   keramida at kobe:/tmp$ cat -n foo
>        1  foo
>        2  bar
>        3  baz
>   keramida at kobe:/tmp$ sed -i '' -e '2d' foo
>   keramida at kobe:/tmp$ cat -n foo
>        1  foo
>        2  baz
>   keramida at kobe:/tmp$
> 
> Look at the manpage of sed for more details about the -i option, and
> consider using backup files while you are running tests.  In-place
> editing is very cool, but it can also make changes that are difficult
> to recover from.
> 
thanks much.  it works just fine in-place.  ...but i did made a separate
copy, just in case;-)




More information about the freebsd-questions mailing list