From owner-freebsd-questions@FreeBSD.ORG Wed Jun 20 01:35:40 2007 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 1B15C16A41F for ; Wed, 20 Jun 2007 01:35:40 +0000 (UTC) (envelope-from frank@esperance-linux.co.uk) Received: from mailout.zetnet.co.uk (mailout.zetnet.co.uk [194.247.47.231]) by mx1.freebsd.org (Postfix) with ESMTP id D074713C45D for ; Wed, 20 Jun 2007 01:35:39 +0000 (UTC) (envelope-from frank@esperance-linux.co.uk) Received: from irwell.zetnet.co.uk ([194.247.47.48] helo=zetnet.co.uk) by mailout.zetnet.co.uk with esmtp (Exim 4.50) id 1I0keY-0002ux-PR for freebsd-questions@freebsd.org; Tue, 19 Jun 2007 21:50:18 +0100 Received: from esperance.zetnet.co.uk (54-144.adsl.zetnet.co.uk [194.247.54.144]) by zetnet.co.uk (8.13.8/8.13.8/Debian-3) with SMTP id l5JKoHB7003970 for ; Tue, 19 Jun 2007 21:50:18 +0100 Received: (qmail 7252 invoked by uid 1001); 19 Jun 2007 20:50:12 -0000 From: "Frank Shute" Date: Tue, 19 Jun 2007 21:50:12 +0100 To: Olivier Regnier Message-ID: <20070619205012.GA6984@melon.esperance-linux.co.uk> References: <46780B29.7000004@oregnier.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <46780B29.7000004@oregnier.net> User-Agent: Mutt/1.4.2.2i X-Operating-System: FreeBSD 6.2-RELEASE-p1 i386 X-Organisation: 'Esperance Linux' X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.0.2 (zetnet.co.uk [194.247.46.1]); Tue, 19 Jun 2007 21:50:18 +0100 (BST) Cc: freebsd-questions@freebsd.org Subject: Re: problem with sed substitution X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Frank Shute List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jun 2007 01:35:40 -0000 On Tue, Jun 19, 2007 at 06:58:17PM +0200, Olivier Regnier wrote: > > Hi everyone, > > I try to use sed with /etc/gettytab file. I would like to replace this > text : > \r\n%s\%m ($h) (%t)\r\n\r by Hello world. > I tested with this command : > % sed -i.old -e 's/\r\n%s\%m ($h) (%t)\r\n\r/Hello world/' > but that doesn't work at all. > Can you help me please ? > > Thank you :) > You have to backslash escape the characters "\()% " So eg: cat /etc/gettytab | \ sed -E 's/\\r\\n\%s\/\%m\ \(\%h\)\ \(\%t\)\\r\\n\\r/Hello world/' > ~/new_getty PS: I checked it on my gettytab which looks like it's a bit different to yours. BTW, re_format(7) is worth a look. -- Frank echo "f r a n k @ e s p e r a n c e - l i n u x . c o . u k" | sed 's/ //g' --->PGP keyID: 0x10BD6F4B<---