[texhax] Migrating from Windows to Mac

Tom Backer Johnsen backer at psych.uib.no
Mon Dec 14 20:36:27 CET 2009


Tom Schneider wrote:
>>> You can convert your files by opening a terminal in OSX and doing:
>>>
>>> $ tr -d '\r' < inputfile > outputfile
>>>
>>> which removes the return present at the end of each line in a Windows file.
>>> (Windows has linefeed + return, unix has just linefeed).
>>>
>>> I'm pretty sure OSX has tr.
>>>
>>> If you want to convert a whole load of tex files:
>>>
>>> $ cd <your tex files dir>
>>> $ mkdir unix
>>>
>>> $ for file in $(ls | grep 'tex');do
>>> tr -d '\r' < $file > ./unix/$file
>>> done
>>>
>>> Regards,
>>>   
>>>       
>> Yes 'tr' is there on OS X, i've checked.  But when I tried the command 
>> in a terminal, I only got a feedback on usage for the command rather 
>> than a converted file.
>>     
>
> I use this script:
> ********************************************************************************
> #!/bin/csh -f
> #(ie run the cshell on this but don't read the .cshrc)
>
> # nom: no ^M: remove control M's from a file!
>
> #    version = 1.01 of nom 2009 nov 21
> # 2009 nov 21, 1.01: avoid illegal byte sequence problem
> # 2009 Jul 11 origin
>
> # avoid Illegal byte problem on Macs:
> setenv LC_ALL en_US.ISO8859-1
>
> tr -d '^M' < $1 > $2
>
> ********************************************************************************
>
> where the ^M is a control-M.  You will have to do this in vi or vim
> by replacing the two characters with a control M.  One types:
> /\^M[return]c2l[control-v][control-m]:wq
> \r should work too though.
>
> Note the setenv that makes tr on a Mac happy with unicode characters
> that would otherwise crash it.  This should not be an issue for tex
> files but can be for others.
>
> Tom (yet another!)
>
>   Dr. Thomas D. Schneider
>   National Institutes of Health
>   schneidt at mail.nih.gov
>   toms at alum.mit.edu (permanent)
>   http://alum.mit.edu/www/toms (permanent)
>   
Thank you for the information.  The command you recommended worked, or 
at least without yielding an error message.  However, I had the same 
error message as before:

This is pdfTex, Version 3 ...
entering extended mode
(.second.tex
! Undefined control sequence.
1.5 \documentclass
    [10pt,a4paper]{article}

So, assuming that your command worked, it cannot be the line endings.

Tom


More information about the texhax mailing list