Date: Sun, 21 Dec 2008 07:42:47 +0200 From: Giorgos Keramidas <keramida@ceid.upatras.gr> To: Gary Kline <kline@thought.org> Cc: FreeBSD Mailing List <freebsd-questions@freebsd.org> Subject: Re: Sed question Message-ID: <877i5unkx4.fsf@kobe.laptop> In-Reply-To: <20081221053407.GA87868@thought.org> (Gary Kline's message of "Sat, 20 Dec 2008 21:34:10 -0800") References: <20081221053407.GA87868@thought.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 20 Dec 2008 21:34:10 -0800, Gary Kline <kline@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@kobe:/tmp$ cat -n foo 1 foo 2 bar 3 baz keramida@kobe:/tmp$ sed -i '' -e '2d' foo keramida@kobe:/tmp$ cat -n foo 1 foo 2 baz keramida@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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?877i5unkx4.fsf>