How to convert Line endings of text files
I have been working my way trough a book on shell scripts. Cool book so far. I started to write a script with VI in a terminal on my my Mac Book. I then scp'd it to my linux box and finished writing it in VI on my Linux box. When I run it I get the error "line 45: syntax error: unexpected end of file" My script ends on line 44. All I can think of is the line endings are different between Mac and Linux and that is what is wrong. I know that there is dos2linux for dos to linux file conversions. Is there any thing for mac to linux?
|
Can you post the script. It's far more likely you've missed a closing quote somewhere, and the shell hasn't found it by the end. AFAIK MAc and other Unix have the same line endings. Maybe it's worth a try with dos2unix anyway,
|
Nope, he's right.
Linux use LF Dos uses CR/LF Mac uses CR Code:
tr '\015' '\012' < file.mac > file.unix Cheers, Tink |
I will go ahead and post the script but you were right. if and fi, damn dyslexia gets me every time. It was the last fi that I typed as an if. Thank you any way.
#!/bin/sh |
Tinkster,
Can you explain what this code is doing? more exact the '\015' '\012' thanks Quote:
|
Quote:
tr replaces any occurrence of the first in the input stream with the second. Cheers, Tink P.S. Can you do me a favour and don't use top posting when quoting? Ta. |
All times are GMT -5. The time now is 04:58 AM. |