windows编写的shell脚本运行报错:$'\r'
报错如下所示:

处理:
1、vim -b shell.sh //如下可看到结果的^M字符,也就是windows下的'\r'换行符

2、可以在二进制模式下直接删除,也可以在命令行模式下执行:
:%s:^M::g
注意: ^M是一个字符,不是^ + M 。输入方法是:ctrl + v 再 ctrl m
相关推荐
IDEA中编写并运行shell脚本的实现
主要介绍了IDEA中编写并运行shell脚本的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
shell,bat脚本运行java程序
shell,bat脚本运行java程序, shell,bat脚本运行java程序,
windows shell 脚本
可在windows上运行的几个shell脚本, 使用方法: 1.将下载的bin目录复制到C:\Program Files\Bitvise SSH Server\ 2.执行runAutoRun
python编写shell脚本
python编写shell脚本python编写shell脚本python编写shell脚本python编写shell脚本python编写shell脚本python编写shell脚本python编写shell脚本python编写shell脚本python编写shell脚本python编写shell脚本
运行Shell文件.sh报错syntax error near unexpected token `$’do\r”
问题 运行 sh start.sh,出现报错 start.sh: line 17: syntax error near unexpected token `$'do\r'' 'tart.sh: line 17: ` do 原因 运行cat -v start.sh,如果内容结尾为是^M,这是因为你所处理的文件换行符是dos格式的”\r\n”,你可能在windows下编辑过内容 cat -v start.sh 解决 方法一:运行sed ‘s/\r//g’ start.sh > start2.sh,需要重新命名 sed 's/\r//g' start.sh > start2.sh 方法二:每行


