我正在尝试创建一个简单的shell脚本来ping一个源但我得到了
bash-2.03$ ./test.sh google.com 10 .5 /home/users/me 16 256
./test.sh: line 35: syntax error near unexpected token `(('
./test.sh: line 35: `for (( i = 1 ; i <= $totalArguments ; i++ ))'
这是代码:
#!/bin/bash
ip=$1
count=$2
interval=$3
outputDirectory=$4
shift;
shift;
shift;
shift;
totalArguments=$#
for (( i = 1 ; i <= $totalArguments ; i++ ))
do
ping -c $count -i $interval -s ${!i} $ip >> $outputDirectory/${!i}results.txt
done
有人可以告诉我,我对for循环语法做错了吗? 谢谢!