Windows files and Unix files (Redhat, Ubuntu, etc) are encoded in different ways. Namely, the end of line that is a part of most files created in Windows is not compatible with Unix. You can usually see this because there is a ‘weird character’ at the end of each line. ‘cat’ does not show it, but ‘cat -e’ will show these characters:

xx.xx.125.240 spc240.xx.xx^M$
xx.xx.125.241 spc241.xx.xx^M$

The ^M is a Windows ‘End of Line’ character.

Fortunately there is an easy way to fix these for using them in a unix based system.

Install ‘dos2unix’, and then run the file through them:

dos2unix filename

You can even run these on a bunch of files:

[root@ns1 ~]# dos2unix RDNS-*
dos2unix: converting file RDNS-xx.xx.81 to UNIX format …
dos2unix: converting file RDNS-xx.xx.82 to UNIX format …
dos2unix: converting file RDNS-xx.xx.85 to UNIX format …
dos2unix: converting file RDNS-xx.xx.95 to UNIX format …
dos2unix: converting file RDNS-xx.xx.100 to UNIX format …

‘cat -e’ will show that these files are fixed.

You can also use the program ‘recode’.

You May Also Like

Memory Allocation Problems on Xen Server & Fix

Recently I started seeing this error while provisioning Xen VPSes on a…

Pictomio – Image Catalog Software uses 3D Accelleration

Adobe take note – you need to add 3D acceleration to your…

One Line Linux Command to Print Out Directory Tree Listing

My professor sent us this little one liner (ok, I had to…

Permissions error while using system MySQL folder and Docker

Recently I ran into a permissions issue when running MySQL in a docker container and using a local host’s directory with a restore of a MySQL. The fix for this is an easy one, once you know where to look.