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.

同事反馈他在一测试服务器(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使之生效,问题解决。

相关文章
|
2月前
|
Python
解决安装ConcurrentLogHandler报错error in ConcurrentLogHandler setup command: use_2to3 is invalid.
本文介绍了在Python环境下安装ConcurrentLogHandler时遇到的"use_2to3 is invalid"错误的解决方法,主要是通过降级setuptools到57.5.0版本来解决该问题。
109 2
|
Java Shell 程序员
解决:bash: syntax error near unexpected token `(‘ ...【亲测有效】
解决:bash: syntax error near unexpected token `(‘ ...【亲测有效】
8982 0
|
Java
Appium问题解决方案(8)- selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Could not sign with default certificate.
Appium问题解决方案(8)- selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Could not sign with default certificate.
1046 0
Appium问题解决方案(8)- selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Could not sign with default certificate.
|
5月前
|
Unix Linux Shell
syntax error: unexpected end of file
syntax error: unexpected end of file
21 0
|
5月前
|
开发者 iOS开发
no identity found Command CodeSign failed with a nonzero exit code
no identity found Command CodeSign failed with a nonzero exit code
57 0
error C2449: found ‘{‘ at file scope (missing function header?)和error C2059: syntax error : ‘}‘
error C2449: found ‘{‘ at file scope (missing function header?)和error C2059: syntax error : ‘}‘
107 0
Uniapp Syntax Error: Error: Unbalanced delimiter found in string
Uniapp Syntax Error: Error: Unbalanced delimiter found in string
225 0
使用 spritesmith 报错 Error: Invalid file signature
使用 spritesmith 报错 Error: Invalid file signature
118 0
使用 spritesmith 报错 Error: Invalid file signature
configure: line syntax error near unexpected token `win32-dll'
configure: line syntax error near unexpected token `win32-dll'
344 0
configure: error: You requested LIBYUV but not found...die
configure: error: You requested LIBYUV but not found...die
88 0