-1
#!/bin/bash
array=($1 $2 $3 $4)
if [ "$#" -ne 4 ]; then 
echo "Please enter Names"
else
for i in 1 2 3 4 5 
do 
echo "Welcome $i times"
done
echo "The Name is: "
fi

我在 shell 脚本中遇到语法错误:Unexpected token fi. 请指导我在脚本中做错了什么。

4

1 回答 1

0

你的脚本对我有用,在GNU bash, version 4.2.39

$ ./test A B C D
Welcome 1 times
Welcome 2 times
Welcome 3 times
Welcome 4 times
Welcome 5 times
The Name is: 
$ cat test
#!/bin/bash
array=($1 $2 $3 $4)
if [ "$#" -ne 4 ]; then 
echo "Please enter Names"
else
for i in 1 2 3 4 5 
do 
echo "Welcome $i times"
done
echo "The Name is: "
fi
于 2012-12-18T11:34:18.047 回答