From owner-freebsd-questions@FreeBSD.ORG Thu Jul 21 07:01:54 2011 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 DD5381065672 for ; Thu, 21 Jul 2011 07:01:53 +0000 (UTC) (envelope-from MTaylor@bytecraft.com.au) Received: from bcmelmx.bytecraft.au.com (bcmelmx.bytecraft.au.com [203.39.118.2]) by mx1.freebsd.org (Postfix) with ESMTP id 3DD288FC0C for ; Thu, 21 Jul 2011 07:01:52 +0000 (UTC) Received: from svmailmarshal.bytecraft.internal (svmailmarshal.bytecraft.internal [10.48.0.3]) by bcmelmx.bytecraft.au.com (8.13.8/8.12.11) with ESMTP id p6L6SvDR083648; Thu, 21 Jul 2011 16:28:57 +1000 (EST) (envelope-from MTaylor@bytecraft.com.au) Received: from svmailmel.bytecraft.internal (Not Verified[10.48.0.24]) by svmailmarshal.bytecraft.internal with MailMarshal (v6, 8, 4, 9558) id ; Thu, 21 Jul 2011 16:28:56 +1000 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Date: Thu, 21 Jul 2011 16:28:56 +1000 Message-ID: In-Reply-To: <4e281697.2F3Hm7eEgDK4U/K6%perryh@pluto.rain.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: thread-topic: scrpt help neded... thread-index: AcxHZUMwbtHm6mjJS6SkzS1K7xkKuQACX77Q From: "Murray Taylor" To: , Cc: freebsd-questions@freebsd.org Subject: RE: scrpt help neded... 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: Thu, 21 Jul 2011 07:01:54 -0000 -----Original Message----- From: owner-freebsd-questions@freebsd.org [mailto:owner-freebsd-questions@freebsd.org] On Behalf Of perryh@pluto.rain.com Sent: Thursday, 21 July 2011 10:08 PM To: kline@thought.org Cc: freebsd-questions@freebsd.org Subject: Re: scrpt help neded... Gary Kline wrote: > I'm looking for a script that takes on arg and lets me vi/vim > into the r esults. Let's say that I'm looking for the string > 201107 in a slew of files. the script find it with grep---not > grep -w, just grep. collect es the filenames and lines (grep -n) > and saves then temporarily, then points vim or vi at each > file+linenumbr and execs it for me. the fewer keystrokes, the > better. To edit each file that contains 201107: =20 $ vi ` grep -l 201107 {files to be searched} ` That won't pre-position within the files, but since it's a single invocation of vi, with each subsequent file being loaded by :n, a search pattern will persist (unless/until you replace it by entering a different search pattern). At the top of the first file, you enter =20 /201107 to find the first instance, "n" to find the second, etc. After :n -- at the top of the second file -- "n" alone will find the first instance. OTOH if you want to bring up an xterm containing _the results of the grep_ you can pipe it into the attached script. There is no manpage, but the comments and the (straightforward) parameter decoding should provide a start. (There are a few "magic numbers", which ideally should be tweaked for your X11 installation's font dimensions, but nothing horrible will happen if they are slightly off.) ----- get your grep script to return the line number of the item to be changed and=20 then use vi -c filename .... this is preposition you on the line containing the grepped target. =20 --=20 Murray Taylor Bytecraft Systems Special Projects Engineer =20|_|0|_| "Absence of evidence =20|_|_|0| is not evidence of absence" =20|0|0|0| Carl Sagan =20 --------------------------------------------------------------- The information transmitted in this e-mail is for the exclusive use of the intended addressee and may contain confidential and/or privileged material. Any review, re-transmission, dissemination or other use of it, or the taking of any action in reliance upon this information by persons and/or entities other than the intended recipient is prohibited. If you received this in error, please inform the sender and/or addressee immediately and delete the material.=20 E-mails may not be secure, may contain computer viruses and may be corrupted in transmission. Please carefully check this e-mail (and any attachment) accordingly. No warranties are given and no liability is accepted for any loss or damage caused by such matters. --------------------------------------------------------------- ### This e-mail message has been scanned for Viruses by Bytecraft ###