Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: Removing Hidden Windows Charactes From Files  (Read 1834 times)

0 Members and 1 Guest are viewing this topic.

jominj

  • Guest
Removing Hidden Windows Charactes From Files
« on: January 21, 2014, 07:03:54 am »
While editing files on a machine running Windows and uploading them to a Linux server is convenient, but this may lead to problems. Windows-based text editors put special characters at the end of lines to denote a line return or newline. Some applications on a Linux server cannot understand these characters and can cause the service to not respond correctly. There is a simple way to correct this problem: dos2unix.

Below is an example from a php.ini file showing what the hidden characters look like:
Code: [Select]
;;;;;;;;;;;;;;;;;;;^M
; Resource Limits ;^M
;;;;;;;;;;;;;;;;;;;^M
;^M
max_execution_time = 30^M
max_input_time = 60^M
memory_limit = 32M^M

This will not be appear in windows editors but appear in Linux editors. We can convert this using the command: dos2unix  /path/to/file
For example :
Code: [Select]

root@host [~]# dos2unix /usr/local/lib/php.ini
dos2unix: converting file /usr/local/lib/php.ini to UNIX format ...

That's it now the file will not contain any special windows characters.
Code: [Select]
;;;;;;;;;;;;;;;;;;;
; Resource Limits ;
;;;;;;;;;;;;;;;;;;;
;
max_execution_time = 30
max_input_time = 60
memory_limit = 32M