Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
05-12-2003, 06:11 AM
|
#1
|
Senior Member
Registered: Nov 2001
Location: Budapest, Hungary
Distribution: SuSE 6.4-11.3, Dsl linux, FreeBSD 4.3-6.2, Mandrake 8.2, Redhat, UHU, Debian Etch
Posts: 1,126
Rep:
|
Sed - suitable to replace CR LF?
I would like to convert a regular WinDOS text file to unix text.
First I thought I could do it with sed, but it does not seem so:
sed s/.$//g # removes CRs, but also damages the file: it cuts off the last character of the last line, which never happens to be a CR
sed s/^M//g # does nothing, CRs remain in the file
Could you help me with a working sed example for this task?
Last edited by J_Szucs; 05-12-2003 at 06:12 AM.
|
|
|
05-12-2003, 06:36 AM
|
#2
|
Senior Member
Registered: Dec 2002
Location: Mosquitoville
Distribution: RH 6.2, Gen2, Knoppix,arch, bodhi, studio, suse, mint
Posts: 3,305
Rep:
|
|
|
|
05-12-2003, 11:52 AM
|
#3
|
Senior Member
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536
Rep:
|
Some Distro's (at least Debian) include the dos2unix and unix2dos utilities especially for this.
|
|
|
05-12-2003, 07:03 PM
|
#4
|
Senior Member
Registered: Nov 2001
Location: Budapest, Hungary
Distribution: SuSE 6.4-11.3, Dsl linux, FreeBSD 4.3-6.2, Mandrake 8.2, Redhat, UHU, Debian Etch
Posts: 1,126
Original Poster
Rep:
|
Thanks for the tips.
tr -d '\015' worked!
Maybe sed would have worked, too, if I knew how to quote CR.
Now I know this might have worked: sed s/'\r'//g.
But I will not try it since I already have the solution using tr.
As for dos2unix: it was originally not on my system (an other kind of unix, not Linux); last year I downloaded it as a perl script, but it never seemed to work as expected.
|
|
|
All times are GMT -5. The time now is 08:30 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|