歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> 學習Linux >> Linix登錄報"/etc/profile: line 11: syntax error near unexpected token `${\r",linixsyntax

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

日期:2017/3/3 18:08:55   编辑:學習Linux

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

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


同事反饋他在一測試服務器(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 () {

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

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

http://xxxxxx/Linuxjc/1170158.html TechArticle

Copyright © Linux教程網 All Rights Reserved