Linux下去掉^M的方法
来源:互联网 发布:中科院的飞箭软件 编辑:程序博客网 时间:2024/06/15 21:54
昨天在登陆云服务器时候报错。
-bash: $'\r': command not found-bash: $'\r': command not found-bash: $'\r': command not found-bash: /etc/profile: line 11: syntax error near unexpected token `$'{\r'''bash: /etc/profile: line 11: `pathmunge () {
后面发现是自己傻逼的把profile在windows上写了传上去的。
用/bin/cat -v /etc/profile看到很多^M,是因为Windows下的换行符的原因。
现在在linux下面删了就行,我用的第一种方法。
第一种方法(先yum install -y dos2unix):
cat -A filename 就可以看到windows下的断元字符 ^M
要去除他,最简单用下面的命令:
dos2unix filename
第二种方法:
sed -i 's/^M//g' filename
注意:^M的输入方式是 Ctrl + v ,然后Ctrl + M
第三种方法:
vi filename
:1,$ s/^M//g
^M 输入方法: ctrl+V ,ctrl+M
第四种方法:
cat filename |tr -d ‘/r’ > newfile
^M 可用 /r 代替
0 0
- Linux下去掉^M的方法
- Linux下去掉^M的方法
- Linux下去掉^M的方法
- Linux下去掉^M的方法
- Linux下去掉^M的方法
- Linux下去掉^M的方法
- Linux下去掉^M的方法
- Linux下去掉^M的方法
- Linux下去掉^M的方法
- Linux下去掉^M的方法
- Linux下去掉^M的方法
- Linux下去掉^M的方法
- Linux下去掉^M的方法
- Linux下去掉^M的方法
- linux下去掉文件中^M的方法
- linux下去掉文件中^M的方法
- linux下去掉文件中^M的方法
- linux 下去掉^M
- 重定向
- Spring4新特性——更好的Java泛型操作API
- VS插件下载
- Spring漂流记(一)--Spring概况
- struts2默认Action
- Linux下去掉^M的方法
- glide:源码解析
- 比特币源码学习笔记(二)
- 264. Ugly Number II
- 【CQOI2009】跳舞 网络流
- 后台管理UI的选择
- Android studio学习笔记一
- Cable master
- 树的非递归后续遍历——Java