想請問像下面簡單的1加到100
#!/bin/bash
s=0
for (( i=1; i<=100; i=i+1 ))
do
s=$(($s+$i))
done
echo "The result of '1+2+3+...+100' is ==> $s"
原本只會run一次The result of '1+2+3+...+100' is ==> $s
那我在這行s=$(($s+$i))後面加上& 變成s=$(($s+$i))&
這樣子他就會run100次The result of '1+2+3+...+100' is ==> $s
是這樣子的意思嗎??
--
#!/bin/bash
s=0
for (( i=1; i<=100; i=i+1 ))
do
s=$(($s+$i))
done
echo "The result of '1+2+3+...+100' is ==> $s"
原本只會run一次The result of '1+2+3+...+100' is ==> $s
那我在這行s=$(($s+$i))後面加上& 變成s=$(($s+$i))&
這樣子他就會run100次The result of '1+2+3+...+100' is ==> $s
是這樣子的意思嗎??
--
All Comments