昨天在登陸雲服務器時候報錯。
-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 () {
1
2
3
4
5
6
7
8
9
后面發現是自己傻逼的把profile在windows上寫了傳上去的。
用/bin/cat -v /etc/profile看到很多^M,是因為Windows下的換行符的原因。
現在在linux下面刪了就行,我用的第一種方法。
第一種方法(先yum install -y dos2unix):
cat -A filename 就可以看到windows下的斷元字符 ^M
要去除他,最簡單用下面的命令:
dos2unix filename
1
第二種方法:
sed -i 's/^M//g' filename
1
注意:^M的輸入方式是 Ctrl + v ,然后Ctrl + M
第三種方法:
vi filename
:1,$ s/^M//g
^M 輸入方法: ctrl+V ,ctrl+M
第四種方法:
cat filename |tr -d ‘/r’ > newfile
^M 可用 /r 代替
---------------------
作者:不應有的淡定
來源:CSDN
原文:https://blog.csdn.net/shouldnotappearcalm/article/details/64904253
版權聲明:本文為博主原創文章,轉載請附上博文鏈接!