記一次坑爹報錯之旅 -bash: /etc/profile: line 11: syntax error near unexpected token

昨晚修改了環境變量後,進行重置服務時

source /etc/profile

報錯

[root@localhost etc]# source /etc/profile
-bash: /etc/profile: line 11: syntax error near unexpected token `('
-bash: /etc/profile: line 11: `pathmung e() {'

報錯後,查了一晚上分別試了下面幾種方法
文件轉義爲Unix格式的

# 文件轉義爲Unix格式的
dos2unix profile

然後用NotePad++查了行位符
在這裏插入圖片描述
最後羣裏問了下,羣衆的眼睛是雪亮的,由於自己只關注了錯誤本身去查,忽視了裏面內容

[root@localhost etc]# source /etc/profile
-bash: /etc/profile: line 11: syntax error near unexpected token `('
# pathmung e()這裏有個空格的,通過聯繫下文,確實多了一個空格
-bash: /etc/profile: line 11: `pathmung e() {'

然後把空格修復後,又報錯

-bash: rt: command not found

rt這個命令未找到,還是查錯誤本身,翻了一堆博文後,後面有個博主回答讓人汗顏了
https://blog.csdn.net/lb876864380/article/details/79502679

簡單來說Windows下複製的時候export 複製下來只剩了一個rt了。。。,所以報錯了

以後排查問題,還是要多關注報錯內容本身,多檢查檢查本身那裏有特別明顯的錯誤和異常,而不是出了問題就複製粘貼,瀏覽器裏查
白白浪費了昨天好幾個小時

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章