Date: Sat, 22 Nov 2003 10:44:30 -0500 From: Scott W <wegster@mindcore.net> To: Jerry McAllister <jerrymc@clunix.cl.msu.edu> Cc: freebsd-questions@freebsd.org Subject: Re: newbie: use <CR> in RE? Message-ID: <3FBF845E.7040905@mindcore.net> In-Reply-To: <200311221449.hAMEnNT24343@clunix.cl.msu.edu> References: <200311221449.hAMEnNT24343@clunix.cl.msu.edu>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <CR> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3FBF845E.7040905>