A very common problem, but I can not get around it with sed.
I have a script file (command package), say myfile.txt , which will be executed immediately to create a list. Now that I am performing a batch operation, my command line interface clearly shows that it cannot parse the command as a linear feed. ^M added at the end of each line.
I thought sed was the best way to do this. I tried:
sed -e 's/^M/d' myfile.txt > myfile1.txt mv myfile1.txt myfile.txt
This did not work. I also tried this and it did not work:
sed -e 's/^M//g' myfile.txt > myfile1.txt mv myfile1.txt myfile.txt
Then I thought sed takes it as an M character at the beginning of a line and therefore no result. So I tried:
sed -e 's/\^M//g' myfile.txt > myfile1.txt mv myfile1.txt myfile.txt
But no change. Is there a major mistake that I am making? Please advise, as I'm bad at sed .
I found the permission that was supposed to open the file in vi editor and in command mode execute this:
:set fileformat=unix :w
But I want him in sed .
source share