$'\r': command not found

问题描述

用 Pycharm 写.sh脚本,在Linux远程服务器上运行的时候报错

问题分析

https://stackoverflow.com/questions/5230798/r-character-in-shell-script

Your problem is that the file has Windows line endings. This can be caused by editing a file in Windows and trying to run it on a non-Windows system.
意思是文件是Windows系统的结尾符。

解决方法

安装dos2unix包,转换文件,然后再运行脚本

sudo apt install dos2unix # 下载dos2unix,一般需要root权限
dos2unix YourFile.sh # 转换文件
bash YourFile.sh

即可正常运行脚本

posted @   墨莲玦  阅读(54)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 通过 API 将Deepseek响应流式内容输出到前端
点击右上角即可分享
微信分享提示