From owner-freebsd-questions@FreeBSD.ORG Fri May 1 22:18:34 2015 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 0C0DD6AB for ; Fri, 1 May 2015 22:18:34 +0000 (UTC) Received: from mail-ig0-x234.google.com (mail-ig0-x234.google.com [IPv6:2607:f8b0:4001:c05::234]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C9892144D for ; Fri, 1 May 2015 22:18:33 +0000 (UTC) Received: by igblo3 with SMTP id lo3so47471459igb.0 for ; Fri, 01 May 2015 15:18:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=2UCdM8A02QQsedBY4eBSeGWxXMLbD41Q1kpjwjil+c0=; b=NmTq+Z7kSgQXHBJI0KIbSVUxAaiqHBkdP5U2uPlWPUBVk+UwPSDK8ZqWbDNjaRtkh6 yjTF0t5YhANMvmmBF0K9OiSqdGohk5bDiHoc+jfD7gj48m3HCHO89JZzCUA2Lv/7mgWH g/Ub7BZ56MC6Sk7WRt7ZZmKBC0onBXaC68ybPE0yx3D2AMvPZvClBinAjf24fUQLu8wD vw2LZ44NTIgJopljE7dNipGC3JuyMoDYricmS8viwcNROhDzszslkZSAkLSvQvwaUhVQ rylbBjXCltIuRfjqfnS4tedJjNcCizHlW6ePv4ytXf1S9zPf+TUcwKf5d6OX3E6AxS9P c2lw== X-Received: by 10.42.67.80 with SMTP id s16mr16897026ici.25.1430518713206; Fri, 01 May 2015 15:18:33 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.131.194 with HTTP; Fri, 1 May 2015 15:18:12 -0700 (PDT) In-Reply-To: <20150501222634.371373f0@curlew.lan> References: <20150501222634.371373f0@curlew.lan> From: Alex Merritt Date: Fri, 1 May 2015 18:18:12 -0400 Message-ID: Subject: Re: Find and replace content in 100 lines To: Mike Clarke Cc: Nancy Belle , freebsd-questions Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.20 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 22:18:34 -0000 On Fri, May 1, 2015 at 5:26 PM, Mike Clarke wrote: > On Fri, 1 May 2015 16:20:07 -0400 > Alex Merritt wrote: > > > '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. > Hm, yes, the picket fence. How about sed -i .orig -r 's:"((\.\./){3})arch1/arch14":"\1\1foo/foo2/foo3/arch1/arch14":g' input.html Group it and repeat as \1 -Alex