#!/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
. 请指导我在脚本中做错了什么。
你的脚本对我有用,在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