Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Applications > DOS to Unix ascii translator?

DOS to Unix ascii translator?
Thread Tools
vfunct
Fresh-Faced Recruit
Join Date: Nov 2004
Status: Offline
Reply With Quote
Dec 2, 2004, 08:23 PM
 
OK So I have a whole directory hierarchy of code that's in DOS ascii format (their newlines) and I need to translate it to Unix newline format. What would be the best way to do this? Is there a script in OS-X that would do all that for me? I need to translate it into Unix ascii insead of Mac ascii, as it's C++ code for GCC.
     
darkcore
Dedicated MacNNer
Join Date: Apr 2002
Location: Red Bluff, CA
Status: Offline
Reply With Quote
Dec 2, 2004, 08:38 PM
 
it appears someone has written a few shell scripts that do this sort of thing:
http://lists.apple.com/archives/darw.../msg00015.html
     
Mithras
Professional Poster
Join Date: Oct 1999
Location: :ИOITAↃO⅃
Status: Offline
Reply With Quote
Dec 2, 2004, 09:34 PM
 
Hmmm, let me try!
First cd to the appropriate folder. Then do
Code:
find . -type f -print -exec perl -pi.bak -e 's/\015\012?/\n/g' {} \;
This works as long as *every* file is a text file that needs fixing. It could munge up binary files, so if you have some of those, specify the filename suffix as so:
Code:
find . ( -type f ) -and ( -name '*.cpp' -or -name '*.txt' ) -print -exec perl -pi.bak -e 's/\015\012?/\n/g' {} \;
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 11:01 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,