linux脚本中回车或换行command not found

0.背景

win中写好一个shell脚本,脚本里有换行之类的,在linux上跑的时候。

偶尔会遇到这个提示:

 $'\r': command not found

原因:

Win系统的文件换行使用的是\r\n,而Unix系统是\n

扩展:

bash是增强的shell

Bourne Again shell (bash), 正如它的名字所暗示的,是 Bourne shell 的扩展。bash 与 Bourne shell 完全向后兼容,并且在 Bourne shell 的基础上增加和增强了很多特性。bash 也包含了很多 C 和 Korn shell 里的优点。bash 有很灵活和强大的编程接口,同时又有很友好的用户界面。

什么是shell? bash和shell有什么关系?

1.解决

vim打开文件

# 设置格式
:set ff=unix
# 保存
:wq

之后,也可以检查下

# 直接
:set ff

image-20220107192006334

posted @ 2022-01-07 19:23  羊37  阅读(404)  评论(0编辑  收藏  举报