-
Website
http://www.tech-recipes.com/ -
Original page
http://www.tech-recipes.com/rx/200/convert-dos-line-breaks-to-unix-line-breaks/ -
Subscribe
All Comments -
Community
-
Top Commenters
-
davak
83 comments · 1 points
-
danishbacker
9 comments · 1 points
-
flexinfo
11 comments · 1 points
-
bej
4 comments · 1 points
-
dimithri
5 comments · 1 points
-
-
Popular Threads
-
Windows 7: How to Prevent the Mouse from Waking your PC
13 hours ago · 1 comment
-
Outlook 2010: Turn Off Attachment Preview
1 week ago · 1 comment
-
Gmail: How to Send SMS Messages Without Using Email
2 weeks ago · 2 comments
-
Windows 7 – Prevent Live Messenger from Opening at Start Up
1 week ago · 1 comment
-
Symfony: Drop Down List Box Without Submit Button
3 weeks ago · 1 comment
-
Windows 7: How to Prevent the Mouse from Waking your PC
perl -pi -s 'rn/n/' filename
dos2unix filename.
all sequences of the form "1532"...that's wrong
for two reasons.
First, "32" is a typo, that's just
a random control character. "12" is the correct
octal escape for newline (and 15 is carriage
return).
This is better expressed as simply "rn" to avoid
such typos.
Second, you don't want to DELETE the line
ending altogether, you want to CHANGE it.
The quickest fix is to just delete all carriage
returns, leaving the newlines in place:
tr -d '15" < dos-format-file > unix-friendly-file
or better
tr -d "r" < dos_file > unix_file
There's also "dos2unix", which comes with most
Linux/Unix systems I've seen in the last 10 years:
dos2unix -n dos_file new_unix_file
> sed -i "s/r//" file.txt
If you want to keep a backup of the file just specify an extension.
> sed -i.bak "s/r//" file.txt
Above line will create file.txt.bak as a copy of the original file.
all sequences of the form "1532"...that's wrong
for two reasons.
First, "32" is a typo, that's just
a random control character. "12" is the correct
octal escape for newline (and 15 is carriage
return).
</ul>
15 is r. Yes, you do want to delete all r's.
32 is CTRL-Z. DOS text files have an EOF byte: 0x1a or 32 or ^Z. This also removes that character. Yes, you do want to delete all ^Z's.
So this is good advice and does work. Did you try it?
I do agree with the other poster who said to use -i to edit the file in place, though.
tr -d '1532' < teste.f > teste1.f
Cleans up my ctrl-m's but not the final ctrl-z. Anyone would happen to know why?