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