From owner-freebsd-questions@FreeBSD.ORG Sat Nov 22 07:44:35 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A8FCC16A4CE for ; Sat, 22 Nov 2003 07:44:35 -0800 (PST) Received: from ms-smtp-02-eri0.southeast.rr.com (ms-smtp-02-lbl.southeast.rr.com [24.25.9.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id 903D443F3F for ; Sat, 22 Nov 2003 07:44:34 -0800 (PST) (envelope-from wegster@mindcore.net) Received: from mindcore.net (rdu163-100-105.nc.rr.com [24.163.100.105]) hAMFiWNW023624; Sat, 22 Nov 2003 10:44:32 -0500 (EST) Message-ID: <3FBF845E.7040905@mindcore.net> Date: Sat, 22 Nov 2003 10:44:30 -0500 From: Scott W User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20031007 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jerry McAllister References: <200311221449.hAMEnNT24343@clunix.cl.msu.edu> In-Reply-To: <200311221449.hAMEnNT24343@clunix.cl.msu.edu> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit cc: Zhang Weiwu cc: freebsd-questions@freebsd.org Subject: Re: newbie: use in RE? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 Nov 2003 15:44:35 -0000 Jerry McAllister wrote: >>Hello. Just want to know how to use special character in Regular Expression. >> >>I wish to remove all the carrier returns from a text file, I can use: >>tr -d "\r" < text_file > modified_text_file >>But if I do: >>sed -i s/\r//g text_file >>it actually removes all the character "r" from the file. >> >>This is also a problem in vi(1). Besides I wish to manipulate >>tabstops and line-feeds with RE too. >> >> > >So why not just use tr? \t should get tabs, as you noted \r gets CRs >I don't know linefeed off hand, but wouldn't be surprised if it was \l. >It follows the usual conventions. > >There are more things besides -d that you can do with tr also. > >////jerry > > >_______________________________________________ >freebsd-questions@freebsd.org mailing list >http://lists.freebsd.org/mailman/listinfo/freebsd-questions >To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org" > > > You can do what you want in vi or sed, you just need to escape the first escape character, eg sed -i s/\\r//g vi: :/s/\\r//g Note that with your tr string, you're already 'wrapping' the backslash-r in double quotes, thereby avoiding shell expansion.. You can also use the dos2unix command, although I don't see it in ports... Scott