$'\r': command not found 发表于 2021-12-09 分类于 零碎 阅读次数: linux 执行脚本时,出现 $\r: command not found 错误。 问题在 linux 执行脚本时,会出现 "$'\r': command not found" 错误。 原因大概率是由于此脚本是在 windwos 上编辑的,导致其换行符被 windows 改为 \r\n,而 Linux 的换行符为 \n ,多出的 \r 字符 Linux 不认识就会导致这种报错。 解决方法 使用 vim 编辑出现问题的文件 vim xxx.sh 输入 :set ff=unix 输入 :wq 其他具体命令释义可搜索 vim 使用教程