image
image

Go Back   macosx.com > Mac Help Forums > Mac OS X System & Mac Software

Reply
 
Thread Tools
  #1  
Old December 4th, 2001, 12:06 PM
yada yada yada ya
 
Join Date: Mar 2001
Posts: 94
Thanks: 0
Thanked 0 Times in 0 Posts
paulsomm is on a distinguished road
Converting text files from windows to unix (OSX) and back

If you use BBEdit this isn't a big deal, but I use pico a lot for quick edits of files, and a lot of our developers use Windows to edit the files, so the linebreaks are different, which causes pico (or any Unix editor) to open the file all on one line with no line breaks.

A quick, one line way to convert from windows to unix is at the terminal prompt is to type:

tr '\n' '\r' < /path/to/winfile > /path/to/macfile

I usually create two scripts in my /bin folder called "demac" and "tomac". They actually create a backup copy just in case, and then make the new file the same name as the old. you can copy and past the following into Pico and save them:

demac (to convert from mac to windows):

#!/bin/sh
tr '\r' '\n' < $1 > temp
mv $1 $1.bak
mv temp $1



tomac (to convert from windows to mac):

#!/bin/sh
tr '\n' '\r' < $1 > temp
mv $1 $1.bak
mv temp $1


I then type "demac filename" or "tomac filename" and the original is stored as "filename.bak" just in case
Reply With Quote
  #2  
Old December 4th, 2001, 03:23 PM
yada yada yada ya
 
Join Date: Mar 2001
Posts: 94
Thanks: 0
Thanked 0 Times in 0 Posts
paulsomm is on a distinguished road
Re: I have a question

Quote:
Originally posted by testuser
Windows lines end with \r\n
OS X (unix) lines end with \n
Classic Mac OS lines end with \r

Will these scripts result in duplicate line breaks when converting to Mac? (not sure what will happen when converting from Mac to PC)

Or am I mistaken, and can Windows files actually end with just a \r ?
Good question. All I can say is I don't have duplicates.
Reply With Quote
Reply

Thread Tools

Posting 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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
From Windows FTP to OSX w/SharePoints tdurham Mac OS X System & Mac Software 0 February 18th, 2003 06:06 PM
Using Windows USB keyboard with OSX neuroman Mac OS X System & Mac Software 2 June 15th, 2002 05:24 AM
Re-intsalling OSX changed my IP, can get back my old one?! ThE OutsiDer Mac OS X System & Mac Software 2 December 10th, 2001 06:06 PM
Using Windows USB keyboard in OSX neuroman Mac OS X System & Mac Software 3 November 30th, 2001 03:56 PM


All times are GMT -5. The time now is 07:30 AM.


Mac Support® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2000-2008 DigitalCrowd, Inc.