当前位置:网站首页>Shell 脚本参数传递时有 \r 换行符问题
Shell 脚本参数传递时有 \r 换行符问题
2022-07-25 10:20:00 【慌途L】
最近用Nodepad++写Shell脚本进行参数动态传递时,发现有时候参数携带了\r换行符,编辑器里也是Shell脚本的语言。本来一看就知道是换行符的问题,偏偏有的脚本不带\r符号,有的又带,真的迷!

问题原因:
- Unix体系里,每行结尾只有"<换行>”,即"
\n"; - Windows体系里面,每行结尾是"<换行><回 车>”,即"
\n\r”。
所以当从Windows上把脚本放入Linux上后,会把"\n\r”一起带入
解决方法:
allSyncTask.sh:脚本名称,自定义
1.使用命令:
dos2unix allSyncTask.sh
找不到dos2unix命令时,安装dos2unix:
yum install dos2unix
yum install unix2dos
2.去掉"\r"命令:(切记不要使用两个",不然所有带r字母的都会被替换掉)
sed -i "s/\r//" allSyncTask.sh
相关文章
- DataX | 在Liunx上安装和使用.
- DataX | MySQL多表全量同步和多表定时增量同步.
- DataX踩坑1 | 连接数据库失败. 请检查您的 账号、密码、数据库名称、IP、Port.
- DataX踩坑2 | 定时任务crontab不执行或报错:/bin/sh: java: command not found.
边栏推荐
猜你喜欢

Flask framework - Message flash

From the perspective of open source, analyze the architecture design of SAP classic ERP that will not change in 30 years

HCIA实验(08)

The idea has been perfectly verified again! The interest rate hike is approaching, and the trend is clear. Take advantage of this wave of market!

Implementation of recommendation system collaborative filtering in spark

AI technology stack is too huge! Wu Enda gives career planning: lifelong learning

最详细的mysql索引解析(文末附赠思维导图)
Learn NLP with Transformer (Chapter 3)

NB-IOT控制液晶屏(日期的设置与读取)

性能测试中TPS的计算【杭州多测师】【杭州多测师_王sir】
随机推荐
Learn NLP with Transformer (Chapter 7)
Reinforcement Learning 强化学习(四)
Signal integrity (SI) power integrity (PI) learning notes (XXXIII) 102 general design rules to minimize signal integrity problems
I, AI doctoral student, online crowdfunding research topic
Disabled and readonly and focus issues
Implementation of recommendation system collaborative filtering in spark
ESP8266 使用 DRV8833驱动板驱动N20电机
Flask framework -- flask caching
Learn NLP with Transformer (Chapter 4)
The most comprehensive UE4 file operation in history, including opening, reading, writing, adding, deleting, modifying and checking
Learn NLP with Transformer (Chapter 8)
【信息系统项目管理师】思维导图系列精华汇总
API supplement of JDBC
Esp8266 uses drv8833 drive board to drive N20 motor
JDBC的APi补充
【蓝桥杯集训100题】scratch太极图 蓝桥杯scratch比赛专项预测编程题 集训模拟练习题第22题
Understand the life cycle and route jump of small programs
Signal integrity (SI) power integrity (PI) learning notes (XXXIV) 100 rules of thumb for estimating signal integrity effects
Flask框架——消息闪现
Google Earth Engine——统计逐年土地分类的频率