Convert Windows text file to Linux/Unix using Perl

  • warning: Declaration of views_handler_filter::options_validate(&$form, &$form_state) should be compatible with views_handler::options_validate($form, &$form_state) in /web/sites/result42.com/html/sites/all/modules/views/handlers/views_handler_filter.inc on line 0.
  • warning: Declaration of views_handler_filter::options_submit(&$form, &$form_state) should be compatible with views_handler::options_submit($form, &$form_state) in /web/sites/result42.com/html/sites/all/modules/views/handlers/views_handler_filter.inc on line 0.
  • warning: Declaration of views_plugin_style_default::options(&$options) should be compatible with views_object::options() in /web/sites/result42.com/html/sites/all/modules/views/plugins/views_plugin_style_default.inc on line 0.
  • warning: Declaration of views_plugin_row::options_validate($form, &$form_state) should be compatible with views_plugin::options_validate(&$form, &$form_state) in /web/sites/result42.com/html/sites/all/modules/views/plugins/views_plugin_row.inc on line 0.
  • warning: Declaration of views_plugin_row::options_submit($form, &$form_state) should be compatible with views_plugin::options_submit(&$form, &$form_state) in /web/sites/result42.com/html/sites/all/modules/views/plugins/views_plugin_row.inc on line 0.

When writing text file on Windows and then opening them in Linux/Unix you will notice that there are some strange characters at the end of every line.

That is because windows using two characthers for the "return" character. This was useful in the DOS day. But today it is useless but windows is still using it. Nobody has given me a good reason why.

Anyway, This can be quite annoying when working on multiple platforms and if you are on Linux/Unix and have a file saved on Windows and need to convert it.

This can easily be done with a small trick with perl

perl -pi.bak -e 's/\r//g' <filename>

A backup of the original file will be kept with the name <filename>.bak

Tagged:  

( Try Multi Commander, A file manager for professionals )

Copyright (c) 2015 - Mathias Svensson