delete ^M at the end of line

来源:互联网 发布:身材知乎 编辑:程序博客网 时间:2024/05/16 12:46

1. how to denote newline on different OS?

  • windows: 0D0A (\r\n)

  • unixlinux: 0A (\n)

  • MAC: 0D (\r)

2. there are some handy methods to delete ^M:

  • open file with vim
:set fileformat=unix :g/^M/s/^M// or :%s/^M//g
  • sed -i 's/^M//' filename
  • tr -d '\r' ' '
  • dos2unix filename

3.参考文档

原文地址忘记了~

0 0
原创粉丝点击