Ezio's Blog
Posts Categories Tags Music Mood About
Ezio's Blog· Light
☰ Menu
Posts Categories Tags Music Mood About
Expand all Back to top Go to bottom

Linux 错误:$r: command not found

Author: Ezio Date: May 31, 2021  11:00:28 Category: Linux

Linux 错误:$‘\r‘:command not found

在linux系统上执行shell脚本时,如果出现’$‘\r‘:command not found’报错,其原因是:shell脚本在windows系统下进行编辑后上传到linux系统上执行所报的错,因为在windows下换行时回车符+换行符(\r\n),而unix下是换行符(\n),linux下不识别 \r 为回车符,所以导致脚本执行报错,其本质是不同系统的编码问题。

解决方案:

1
2
yum install dos2unix
dos2unix '脚本名.sh'

执行后该命令后再执行原脚本,报错消失。

Author: Ezio

Permalink: https://ezioy.cn/2021/05/31/Linux%E9%94%99%E8%AF%AF%EF%BC%9A%20$'r'%20command%20not%20found/

License: Copyright (c) 2019 CC-BY-NC-4.0 LICENSE

Slogan: Nothing is true,Everything is permitted

Tag(s): # Linux
back · home
理解计算机系统中的局部性原理 HashMap
Ezio © 2019 - 2026 | Powered by Hexo & Chic | 访客数量:   浏览次数: | 渝公网安备50011302222043 | 渝ICP备2023013933号-1