Linix登錄報"/etc/profile: line 11: syntax error near unexpected token `$'{\r''"


同事反饋他在一測試服務器(CentOS Linux release 7.2.1511)上修改了/etc/profile文件后,使用source命令不能生效,讓我幫忙看看,結果使用SecureCRT一登錄就發現下面錯誤信息:

Last login: Fri Nov 4 00:42:45 2016 from 10.20.34.14
 
-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 () {

clip_image001

 

錯誤提示信息已經反饋/etc/profile里面有一些異常,初步檢查/et/profile文件后,沒有發現異常,很是奇怪,后面我使用cat -v /etc/profile檢查,發現里面大量的Windows下的換行符。如下截圖所示

 

clip_image002

 

咨詢了一下他是怎么修改,他反饋是將該文件拷貝出來,然后用文本編輯器修改,然后覆蓋原文件。到這里已經知道具體原因了,使用dos2unix profile將profile文件從Windows格式文件轉換為Unix、Linux格式,然后在執行source profile使之生效,問題解決。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM