From owner-freebsd-questions@FreeBSD.ORG Sun Dec 21 05:42:59 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 38806106564A for ; Sun, 21 Dec 2008 05:42:59 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from igloo.linux.gr (igloo.linux.gr [62.1.205.36]) by mx1.freebsd.org (Postfix) with ESMTP id A6D488FC1F for ; Sun, 21 Dec 2008 05:42:58 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from kobe.laptop (adsl28-172.kln.forthnet.gr [77.49.155.172]) (authenticated bits=128) by igloo.linux.gr (8.14.3/8.14.3/Debian-5) with ESMTP id mBL5gmxk024851 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Sun, 21 Dec 2008 07:42:54 +0200 Received: from kobe.laptop (kobe.laptop [127.0.0.1]) by kobe.laptop (8.14.3/8.14.3) with ESMTP id mBL5gmER027937; Sun, 21 Dec 2008 07:42:48 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Received: (from keramida@localhost) by kobe.laptop (8.14.3/8.14.3/Submit) id mBL5glLr027936; Sun, 21 Dec 2008 07:42:47 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) From: Giorgos Keramidas To: Gary Kline References: <20081221053407.GA87868@thought.org> Date: Sun, 21 Dec 2008 07:42:47 +0200 In-Reply-To: <20081221053407.GA87868@thought.org> (Gary Kline's message of "Sat, 20 Dec 2008 21:34:10 -0800") Message-ID: <877i5unkx4.fsf@kobe.laptop> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-MailScanner-ID: mBL5gmxk024851 X-Hellug-MailScanner: Found to be clean X-Hellug-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-3.865, required 5, autolearn=not spam, ALL_TRUSTED -1.80, AWL 0.53, BAYES_00 -2.60) X-Hellug-MailScanner-From: keramida@ceid.upatras.gr X-Spam-Status: No Cc: FreeBSD Mailing List Subject: Re: Sed question X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Dec 2008 05:42:59 -0000 On Sat, 20 Dec 2008 21:34:10 -0800, Gary Kline 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.