From owner-freebsd-questions@FreeBSD.ORG Fri May 1 21:29:51 2015 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 1A5512B7 for ; Fri, 1 May 2015 21:29:51 +0000 (UTC) Received: from avasout07.plus.net (avasout07.plus.net [84.93.230.235]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (Client CN "Bizanga Labs SMTP Client Certificate", Issuer "Bizanga Labs CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id A7EE01EF5 for ; Fri, 1 May 2015 21:29:49 +0000 (UTC) Received: from curlew.milibyte.co.uk ([80.229.31.82]) by avasout07 with smtp id NlSb1q0051mJoLY01lScmb; Fri, 01 May 2015 22:26:37 +0100 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=fZwjyigF c=1 sm=1 tr=0 a=cd0K7rcWwnZFf6xQxRobyA==:117 a=cd0K7rcWwnZFf6xQxRobyA==:17 a=D7rCoLxHAAAA:8 a=0Bzu9jTXAAAA:8 a=kj9zAlcOel0A:10 a=h1PgugrvaO0A:10 a=pGLkceISAAAA:8 a=_-_VZv_Yf64VByOnLREA:9 a=CjuIK1q_8ugA:10 Received: from curlew.lan ([192.168.1.13]) by curlew.milibyte.co.uk with esmtp (Exim 4.85) (envelope-from ) id 1YoISB-0000ec-Ab; Fri, 01 May 2015 22:26:35 +0100 Date: Fri, 1 May 2015 22:26:34 +0100 From: Mike Clarke To: Alex Merritt Cc: Nancy Belle , freebsd-questions Message-ID: <20150501222634.371373f0@curlew.lan> In-Reply-To: References: X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.27; amd64-portbld-freebsd10.0) MIME-Version: 1.0 X-SA-Exim-Connect-IP: 192.168.1.13 X-SA-Exim-Mail-From: jmc-freebsd2@milibyte.co.uk X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on curlew.lan X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 Subject: Re: Find and replace content in 100 lines Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-SA-Exim-Version: 4.2 X-SA-Exim-Scanned: Yes (on curlew.milibyte.co.uk) X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 May 2015 21:29:51 -0000 On Fri, 1 May 2015 16:20:07 -0400 Alex Merritt wrote: > You want sed with the search/replace feature, generally: > > sed s/regular expression/replacement/flags > > like so > > > 's:"../../../arch1/arch14":"../../../../../../foo/foo2/foo3/arch1/arch14":g' > input.html Although that would almost certainly work OK in the OP's case it would be safer to use: 's:"\.\./\.\./\.\./arch1/arch14":"../../../../../../foo/foo2/foo3/arch1/arch14":g' otherwise if there was something like "../../d1/arch1/arch14" it would become "../../../../../../foo/foo2/foo3/arch1/arch14" which is probably not what would be intended. -- Mike Clarke