8:37 AM Perl trick to remove Ctrl - M charater from a file |
Hello open system guys, we always get into situation where by we have to copy files from windows to/from Linux/UNIX/AIX syetsm. When this happens there is pretty much a chance that the ctrl - M character may be found in the files we receive from Window system.
If there is a control - M character in a batch or a script , the script will failed as hell saying "command not found" The resolution is we have to remove them. In today's article i will tell you how to do this using perl command. I have already shared the linux/Unix command to do so at here
Simply use the below command : perl -p -i -e 's/\r\n$/\n/g;' <filename> The above command will work on the <filename> directly and remove any or all ctrl-M characters.in it. Description: It simply replaces '/r' by nothing. '/r' is a special character for ^M or ctrl - M. g --- globally s --- substitite
If you like it share it..!
|
|
|
Related blogs
You may also like to see:
| [2014-12-03] | [Open System-Linux] |
| | |
| [2015-06-16] | [Open System-Linux] |
Alien command : convert files from one form to another, install binary packages | |
| [2016-05-24] | [Open System-Linux] |
FACTER command in Linux : showing system facts | |
| [2017-08-22] | [Open System-Linux] |
Difference between tailf and tail -f in Linux | |
| [2016-02-05] | [Open System-Linux] |
Lets try to understand sticky bit concept in Linux! | |
| Total comments: 0 | |
Alien command : convert files from one form to another, install binary packages
FACTER command in Linux : showing system facts
Difference between tailf and tail -f in Linux
Lets try to understand sticky bit concept in Linux!