Bash:意外标记“完成”附近的语法错误

Edu*_*duc 2 shell-script

我写了这个脚本

#!/bin/bash

if [ $# -ne 2 ] ;

 then

echo "\n      Usage : sh $0 BSSID interface   \n"

exit 0;
fi
while true;

 do

reaver -b $1 -i $2 -vv -N -g 10 -S -a

sleep 3603;

done
Run Code Online (Sandbox Code Playgroud)

但我收到了这条消息:

bash T.sh
T.sh :line 2: $'\r':command not found
T.sh :line 10: $'\r':command not found
T.sh :line 27: syntax error near unexpected token 'done'
T.sh: line 27: 'done'
Run Code Online (Sandbox Code Playgroud)

Cit*_*ght 6

脚本看起来没问题。如果您在 Windows 机器上编辑/创建了它并复制到 *nix,'dos2unix' 将解决这个问题。

dos2nix T.sh

如果“dos2unix”返回“未找到命令”消息,请安装“dos2unix”rpm。