Shell - line 2: $‘\r‘: command not found

简介: 拷贝脚本提交后报错 line 2: $'\r': command not found,但是这是别的同学可以运行后发给我的,随后开始排查。安装 dos2unix 需要使用 yum。安装 yum 需要使用 brew。

 一.引言

拷贝脚本提交后报错 line 2: $'\r': command not found,但是这是别的同学可以运行后发给我的,随后开始排查。

image.gif编辑

二.问题解决

任务执行错误是因为原始脚本是在 windows 环境下编写而本机 linux 不识别导致,因此需要将对应文件转化为 linux 版,执行下述命令转换文件 format:

dos2unix file

image.gif

随后提示:

dos2unix: converting file file to Unix format ...

image.gif

同理,如果你的文件是在 linux 编写需要到 windows 环境使用:

unix2dos file

image.gif

三.工具安装

1.安装 dos2unix

安装 dos2unix 需要使用 yum

yum install dos2unix

image.gif

2.安装 yum

安装 yum 需要使用 brew

brew install yum

image.gif


目录
相关文章
|
Java 大数据 Shell
Azkaban--使用实战--shell、command 调度 | 学习笔记
快速学习 Azkaban--使用实战--shell、command 调度
832 0
Azkaban--使用实战--shell、command 调度 | 学习笔记
|
Shell
shell:使用command判断一个命令是否存在
shell:使用command判断一个命令是否存在
304 0
|
Shell Linux Python
shell之用command在终端判断是否存在这个命令
shell之用command在终端判断是否存在这个命令
288 0
|
Shell
Samba MS-RPC Remote Shell Command Execution Vulnerability
 http://www.securityfocus.com/bid/23972/exploit
742 0
|
22天前
|
Java Shell Linux
使用 sh -x 进行 shell 脚本调试
使用 sh -x 进行 shell 脚本调试
34 9
使用 sh -x 进行 shell 脚本调试