0.前言 通常我们在编辑 Linux 服务器上的文件时,直接在 Linux 环境比较麻烦(当然熟练使用 VIM 的程序员除外哈哈),有时我们会使用 Windows 将文件编辑好再上传到服务器端,我用的是 Sublime text . 1.问题描述与记录 编辑完脚本上传到服务器运行时,会出现语法错误,以下面的一小段脚本为例 #!/bin/bash echo "updatedb..." sudo updatedb BASE_PATH=$(dirname $(locate $0)) echo…
https://www.npmjs.com/package/cross-env 跨平台运行脚本 The problem Most Windows command prompts will choke when you set environment variables with NODE_ENV=production like that. (The exception is Bash on Windows, which uses native Bash.) Similarly, there's…
在linux中执行脚本时出错 $'\r': command not found 错误原因是在脚本中有空行,如果脚本是在Windows下进行编辑之后上传到linux上去执行的话,就会出现这个问题. 因为win下的空行是/r/n,但是linux下是/n,没有识别/r,所以会导致上述的报错,这个属于脚本编码的问题. 建议: 在服务器中编写相关脚本,可以有效避免这个问题.…
Centos7下执行shell脚本报错如下 [root@ip---- ~]# sh install_zabbix_agent.sh install_zabbix_agent.: $'\r': command not found install_zabbix_agent.: $'\r': command not found install_zabbix_agent.: $'\r': command not found install_zabbix_agent.: syntax error near…