当前位置:网站首页>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.
边栏推荐
猜你喜欢

Esp8266 uses drv8833 drive board to drive N20 motor

HCIP(11)

代码的表示学习:CodeBERT及其他相关模型介绍

Hucang integrated e-commerce project (II): project use technology, version and basic environment preparation

2021 CEC written examination summary

Hcip experiment (01)

Microwave technology homework course design - Discrete capacitance and inductance + microstrip single stub + microstrip double stub

Kraken中事件通道原理分析

【flask高级】结合源码详解flask的运行机制(出入栈)

The most detailed MySQL index analysis (mind map is attached at the end of the article)
随机推荐
Flask框架——Session与Cookie
HCIA实验(07)综合实验
Learn NLP with Transformer (Chapter 2)
[strategic mode] like Zhugeliang's brocade bag
Openstack Skyline 组件安装
Druid 查询超时配置的探究 → DataSource 和 JdbcTemplate 的 queryTimeout 到底谁生效?
哥廷根大学提出CLIPSeg:一个使用文本和图像prompt能同时作三个分割任务的模型
The University of Gottingen proposed clipseg: a model that can perform three segmentation tasks simultaneously using text and image prompts
Kraken中事件通道原理分析
Dataset and dataloader data loading
SQL语言(五)
性能测试中TPS的计算【杭州多测师】【杭州多测师_王sir】
From the perspective of open source, analyze the architecture design of SAP classic ERP that will not change in 30 years
学习周刊 - 总第 63 期 - 一款开源的本地代码片段管理工具
Tree dynamic programming
The integration of two in one has a long way to go
API supplement of JDBC
Reinforcement Learning 强化学习(三)
Gan, why '𠮷 𠮷'.Length== 3 ??
Code representation learning: introduction to codebert and other related models