我是靠谱客的博主 顺利电源,这篇文章主要介绍行1: 未预期的符号 `$'\r'' 附近有语法错误,现在分享给大家,希望可以做个参考。

从window拷过来的脚本在linux主机上执行报错,如下:

[root@localhost agent]# sh memory
memory:行1: 未预期的符号 `$'r'' 附近有语法错误
'emory:行1: `suninfo()
[root@localhost agent]# vi memory
suninfo()
{
UNAME_M=`uname -m`;
......

但是脚本语法并无错误 , 应该是格式问题 

解决办法:安装一个dos2unix

[root@localhost agent]# yum install -y dos2unix
[root@localhost agent]# dos2unix memory.sh
dos2unix: converting file memory.sh to Unix format ...
[root@localhost agent]#

格式化后执行不报错!

最后

以上就是顺利电源最近收集整理的关于行1: 未预期的符号 `$'\r'' 附近有语法错误的全部内容,更多相关行1:内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(111)

评论列表共有 0 条评论

立即
投稿
返回
顶部