开发者

bash shell program

!/bi开发者_JAVA百科n/bash
echo Enter the num
read n
for i in { 1..10 }
do
m=$(( n*i ))
echo "$i * $n" = $m
done

i got error as

for: 8: Illegal number: { kindly suggest a solution


do it like this

#!/bin/bash
read -p "Enter the num: " n
for i in {1..10}
do
    m=$(( n*i ))
    echo "$i * $n" = $m
done

the shebang is wrong, and don't leave space in brace expansion eg {0..10}, not { 0..10 }


This works in bash:

for (( i=1; i<=10; i++ )); do
    # ...
done
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜