Convert Windows Carriage Returns to Unix

Often times a file edited on the Windows operating system introduces invisible carriage returns to the contents of the file to represent a new line.  The unix based operating system running on ARSC systems is unable to read these Windows carriage returns, therefore users experience trouble when compiling source code and/or processing their input files copied from a Windows environment.  To resolve this issue, users can run a single perl command to strip the carriage returns out of the file:

perl -p -e 's/\r$//' < windowsfile.txt > unixfile.txt  

Alternatively, the user can try the "dos2unix" unix command:

dos2unix   windowsfile.txt   unixfile.txt

Other unix command line tools exist and are nicely explained in Indiana University's Knowledge Base article available at

Back to Top