shell 脚本中的 \r 字符 [英] \r character in shell script
本文介绍了shell 脚本中的 \r 字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在尝试执行 shell 脚本时遇到以下错误,
I get the below error while trying to execute a shell script,
$'\r': command not found: line 2:
请提出相同的解决方案.
Please suggest a solution for the same.
以下是脚本中使用的初始行,
Below are the intial lines used in the script,
#!/bin/sh
if [[ $# -lt 1 ]]; then
echo "ERROR Environment argument missing <dev,test,qa,prod>"
export RC=50
exit $RC
fi
推荐答案
你的问题是文件有 Windows 行尾.这可能是由于在 Windows 中编辑文件并尝试在非 Windows 系统上运行它造成的.
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.
您可以使用 dos2unix
转换行尾来解决此问题:
You can fix this problem using dos2unix
to convert the line endings:
dos2unix ConstruedTermsXMLGenerator.sh
在另一个方向进行转换的相应实用程序是unix2dos
.
The corresponding utility to convert in the other direction is unix2dos
.
有些系统有fromdos
和todos
.
这篇关于shell 脚本中的 \r 字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文