Tips & Tricks: Removing ^M from files in unix

When transferring files between Windows and Unix you may find that on occasions your file has been modified and that ^M characters exist at end of lines.  This problem is caused when files are transferred to the server as Binary. However if you change the type to ASCII then you will find that the ^M characters are not added. If however you find the file has ^M characters then Unix provides a handy dos2unix command to strip the unwanted ^M characters.  For full reference unix2dos is also provided to format the file back.

dos2unix usage:

dos2unix <file> <output_file>
// Tips & Tricks // Unix //

Comments & Questions

Add Your Comment