---
title: 执行.sh脚本，报$'\r': command not found异常-昇腾社区
description: 执行.sh脚本，报$'\r': command not found异常。
keywords: sh脚本;换行符
url: https://www.hiascend.com/document/caselibrary/detail/mindxdl_0031
section: (其他)
---

# 执行.sh脚本，报$'\r': command not found异常-昇腾社区

URL: https://www.hiascend.com/document/caselibrary/detail/mindxdl_0031
描述: 执行.sh脚本，报$'\r': command not found异常。
关键词: sh脚本;换行符

昇腾文档 [了解详情](https://www.hiascend.com/document)

故障案例 [了解详情](https://www.hiascend.com/document/caselibrary)

执行.sh脚本，报$'\r': command not found异常

执行.sh脚本，报$'\r': command not found异常

2025/01/26

1.5k

问题信息

| 问题来源 | 产品大类 | 关键字 |
| --- | --- | ---|
| 官方 | 集群调度 | sh脚本、换行符 |

#### 问题现象描述

执行.sh脚本，报$'\r': command not found异常。

#### 原因分析

Windows系统下的换行符为\r\n，Linux下的换行符是\n。如果.sh脚本中有换行符在Windows上编写后，直接上传到Linux系统执行，由于Linux无法识别\r命令，就会报$’\r’: command not found异常。

#### 解决措施

在Linux上执行sed -i 's/\r//' *.sh命令，删除.sh脚本中的\r字符。

本页内容

- 问题信息
- 问题现象描述
- 原因分析
- 解决措施
