The only way I know of is manually as follows:
To remove for example ^M from a file:
vi the file name that has ^M at the end of each line.
Hit <Esc>
Type :g/
Hold the CNTRL key and press V and M then release the CNTRL key At the buttom you should see this by now: :g/^M
Then type /s///g at the end of the line. You should see this g/^M/s///g now.
Hit <enter>. All ^M at the end of each line should go away by now.
Save the file and exit.
Good luck
Yoda
April 2, 2013, 12:15pm
2
That ^M
control-M is a CR (carriage return).
As per ASCII table the octal code for CR is 015
. So we can remove it using below sed
:
sed 's/'"$(printf '\015')"'$//g' inputfile > outputfile
RudiC
April 2, 2013, 12:33pm
3
Knowing that AIX is a bit tight when it comes to generic and versatile tools, I still would like to propose any of recode
, iconv
, and dos2unix
, which all can do more than just deleting the ^M at EOL. tr
would help as well.
tr should be present on any UNIX, while dos2unix is rare.
tr -d '\r' < inputfile > outputfile