用notepad++编写了一个shell脚本,运行时老是报错:
$ sh exp.sh
exp.sh: line 1: syntax error
near unexpected token `$'\r''
'xp.sh: line 1: `ERRTRAP()
网上搜索说是window和unix的换行符不同,用notepad++看了一下,如下图
在notepad++的“设置>首选项”中修改新建文档格式为unix,关闭首选项对话框
再重新建一个文档,将上面的内容粘贴过去,查看一下换行符:


再在cygwin下运行,结果如下:
$ sh exp1.sh
exp1.sh: line 12: abc: command not found
[LINE:] Error:
Command or function exited with status 127
[LINE:] Error: Command or function
exited with status 1