From owner-freebsd-questions@FreeBSD.ORG Mon Dec 22 03:31:22 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 B05FF106564A for ; Mon, 22 Dec 2008 03:31:22 +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 2A90D8FC1C for ; Mon, 22 Dec 2008 03:31:21 +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 mBM3VAPP018979 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Mon, 22 Dec 2008 05:31:16 +0200 Received: from kobe.laptop (kobe.laptop [127.0.0.1]) by kobe.laptop (8.14.3/8.14.3) with ESMTP id mBM3V9NK055414; Mon, 22 Dec 2008 05:31:10 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Received: (from keramida@localhost) by kobe.laptop (8.14.3/8.14.3/Submit) id mBM3V8b0055413; Mon, 22 Dec 2008 05:31:08 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) From: Giorgos Keramidas To: Gary Kline References: <20081221053407.GA87868@thought.org> <877i5unkx4.fsf@kobe.laptop> <1229854084.6392.52.camel@ethos> <20081221140658.GA24691@marge.bs.l> <20081221222744.GA28185@thought.org> Date: Mon, 22 Dec 2008 05:31:08 +0200 In-Reply-To: <20081221222744.GA28185@thought.org> (Gary Kline's message of "Sun, 21 Dec 2008 14:27:44 -0800") Message-ID: <87skogj37n.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: mBM3VAPP018979 X-Hellug-MailScanner: Found to be clean X-Hellug-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-3.866, 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-questions@freebsd.org 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: Mon, 22 Dec 2008 03:31:22 -0000 On Sun, 21 Dec 2008 14:27:44 -0800, Gary Kline wrote: > perl -pi.bak -e 's/OLDSTRING/NEWSTRING/g' file1 file2 fileN > > that i swiped somewhere. [?] > > last night i was up until the wee hours coding or extending > a c++ program to assist in this stuff. while i really get > off on hacking code, it's less of a thrill at 02:10, say:_) You don't need C++ for this. If you don't mind the verbosity, Python can do the same thing with: #!/usr/bin/env python import sys skiplines = [1, 3] # line numbers that should be skipped lc = 0 for l in sys.stdin.readlines(): lc += 1 if not (lc in skiplines): print l,