-bash: /etc/profile: line 11: syntax error near unexpected token `$'{\r''报错问题解决
在Linux系统配置Java环境变量之后执行 source /etc/profile指令报:-bash: /etc/profile: line 11: syntax error near unexpected token `$'{\r''如下图:

错误提示信息已经反馈/etc/profile里面有一些异常,初步检查/et/profile文件后,没有发现异常,很是奇怪,后面我使用cat -v /etc/profile检查,发现里面大量的Windows下的换行符。如下截图所示

得知是Linux和windows下的回车换行符不兼容的问题。
所以,剩下的就是去将windows下面的CR LF,转换为Linux下面的LF,即可。
此处,不需要再麻烦地去用其他dos2unix等工具了,notepad++就可以帮忙搞定:
编辑->档案格式转换->转换为UNIX格式:

即可将所有的 CR LF,转换为LF:

所以,越加发现notepad++的强大之处了。
然后再运行此shell脚本,即可正常运行了。
【总结】
linux/cygwin下面的shell脚本出现错误:
syntax error near unexpected token `$’do\r”
是由于该脚本文件是在windows环境下创建编辑的,其默认是将所有的回车变成:
CR加上 LF,而Linux/Unix中的回车只是LF,所以导致解释器不认,出现此错误。
解决办法就是,将所有的CRLF转换为LF即可。
转换的方法有多种,比如用dos2unix,或用此处的notepad++帮我们转换,都可以。
-bash: /etc/profile: line 11: syntax error near unexpected token `$'{\r''报错问题解决的更多相关文章
- Linix登录报"/etc/profile: line 11: syntax error near unexpected token `$'{\r''"
同事反馈他在一测试服务器(CentOS Linux release 7.2.1511)上修改了/etc/profile文件后,使用source命令不能生效,让我帮忙看看,结果使用SecureCRT一登 ...
- 可执行程序无法在Linux上运行,显示line 1: syntax error: word unexpected (expecting ") .
[问题]用arm-linux-gcc编译出来的可执行文件clkCtl,下载到板子上,在Linux下不能运行:./clkCtl: line 1: syntax error: word unexpecte ...
- linux后台执行./run.py提示python syntax error near unexpected token `('
python脚本中的#!/usr/bin/python 估计有不少人注意过一些python脚本开头有这么行东东: #!/usr/bin/python 它是用来干嘛的?貌似没有它对脚本功能也没啥 ...
- libtool: syntax error near unexpected token `]*
../libtool: line 543: syntax error near unexpected token `]*' ../libtool: line 543: ` *[\[\~\#\ ...
- $'\r': command not found 或者 syntax error: unexpected end of file 或者 syntax error near unexpected token `$'\r''
执行shell脚本如果报如下错误: syntax error near unexpected token `$'\r'' syntax error: unexpected end of file $' ...
- Linux 中出现的-bash: syntax error near unexpected token `
版权声明:本文为博主原创文章,未经博主允许不得转载. 在Linux 5中导入数据时,出现下面的错误. -bash: syntax error near unexpected token `(' 检查了 ...
- -bash:syntax error near unexpected token '('
在Xshell5中编写int main(int argc,char** argv)时, 出现-bash:syntax error near unexpected token '(' : 可是我是按照 ...
- line: 1: Syntax error: word unexpected (expecting ")")
开发板上运行可执行程序报出错误: line1: 1: Syntax error: word unexpected (expecting ")") 解决思路: 1.编译器的问题 用a ...
- shell编程报错:“syntax error near unexpected token `”
今天写了个shell脚本,在自己机器上运行正常,给同事,运行报错syntax error near unexpected token `,左看右看shell脚本没有问题,没有办法google搜索,发现 ...
随机推荐
- SAML2.0 SP端处理
sso response解析 import java.io.ByteArrayInputStream; import java.io.InputStream; import java.security ...
- swing 嵌入浏览器
需求要在swing加一个浏览器,在网上找了一个挺方便的方法,现在把代码贴上来 力求方便. package com.vtradex.page.shipment; import static javafx ...
- 关于新学期Python的一点见解
首先很高兴选到了Python,之前学习过c语言,不过学的不大好. 我希望此次课程能够教会我们如何运用Python解决生活中的一些小问题,或者可以解决其他学科上的一些问题,当然有关人工智能方面的最好. ...
- dubbo . dubbo Please check registry access list (whitelist/blacklist) 错误
dubbo Please check registry access list (whitelist/blacklist) dubbo服务调用provider失败.解决办法: 再consumer的服务 ...
- MAC环境配置
必须安装的依赖有:Node.Watchman 和 React Native 命令行工具以及 Xcode. 1.安装homebrew(用brew指令安装其他依赖) /usr/bin/ruby -e &q ...
- gitlab安装部署汉化
1.获取gitlab汉化包(要部署非汉化版,可以跳过这一块内容) 说明:gitlab中文社区版的项目,v7-v8.8是由Larry Li发起的“GitLab 中文社区版项目”(https://gitl ...
- 软件测试day1
Windows基础 一.什么是软件(software) 计算机(computer)=硬件(hardware)+软件(software) 软 件(software)=程序(program)+文档(do ...
- EMF32名词解释
(EFM32)32位节能微控制器(Energy Friendly Microcontroller 32-bit) (Gecko)壁虎 (Starter Kit)入门套件 (STK)入门套件 (Debu ...
- LevelDB源码分析-Write
Write LevelDB提供了write和put两个接口进行插入操作,但是put实际上是调用write实现的,所以我在这里只分析write函数: Status DBImpl::Write(const ...
- 第一周pta作业2
7-2 求最大值及其下标 (20 分) 本题要求编写程序,找出给定的n个数中的最大值及其对应的最小下标(下标从0开始). 输入格式: 输入在第一行中给出一个正整数n(1<n≤10).第二行输入n ...