我正在编写脚本,但在第 2-3 行出现错误。错误是这样打印的:
./ex6.sh: line2: $'\r': command not found
./ex6.sh: line3: syntax error near unexpected token '$'\r''
./ex6.sh: line3: 'fund ()
Run Code Online (Sandbox Code Playgroud)
该文件名为ex6.sh. 有人可以就为什么会发生此错误提供一些指导吗?
#!/bin/sh
func ()
{
if [ "$1" == "" ]; then
echo "Default";
for i in `find` ;
do
if [ -d $i ]; then
echo $i "is a directory";
fi
if [ -f $i ]; then
if [ "$i" != "./script.sh" ]; then
echo $i "is a file";
fi
fi
done
fi
if [ …Run Code Online (Sandbox Code Playgroud) bash ×1