The difference between CRLF and LF

在使用WSL(Windows Subsystem for Linux)时,遇到运行bash脚本实验.sh出错的问题。原因在于WSL将LF视为行结束符,而Windows则使用CRLF。解决方案是将脚本中的CRLF转换为LF。在VSCode编辑器中,可以直接点击红色矩形标记转换行结束符。转换后,脚本即可正常运行。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

The description of the problem

在这里插入图片描述
The scenario where the problem happened is when I JUST run a bash script named experiment.sh.

The solution is change its CRLF to LF.

在这里插入图片描述
Note The editor I use is vscode. You just click the position in red rectangle. You will see the way to change it to LF.
在这里插入图片描述

The major reason for this

is the system I use is WSL that consider LF as line wrap.
The Windows considers the CRLF as line wrap.
reference

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值