bash程式設計小問題!! - Linux

By Frederic
at 2008-09-01T16:31
at 2008-09-01T16:31
Table of Contents
想請問像下面簡單的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
是這樣子的意思嗎??
--
Tags:
Linux
All Comments

By Suhail Hany
at 2008-09-06T13:07
at 2008-09-06T13:07

By Audriana
at 2008-09-10T20:41
at 2008-09-10T20:41

By Quintina
at 2008-09-12T17:53
at 2008-09-12T17:53

By Callum
at 2008-09-15T22:00
at 2008-09-15T22:00

By Victoria
at 2008-09-16T07:07
at 2008-09-16T07:07

By Valerie
at 2008-09-18T09:09
at 2008-09-18T09:09

By Enid
at 2008-09-20T21:09
at 2008-09-20T21:09

By Charlotte
at 2008-09-25T10:30
at 2008-09-25T10:30

By Charlie
at 2008-09-27T09:10
at 2008-09-27T09:10

By Kristin
at 2008-10-01T16:05
at 2008-10-01T16:05

By Quanna
at 2008-10-02T17:10
at 2008-10-02T17:10

By Carolina Franco
at 2008-10-03T07:12
at 2008-10-03T07:12

By Ina
at 2008-10-06T02:21
at 2008-10-06T02:21

By Mary
at 2008-10-09T03:03
at 2008-10-09T03:03
Related Posts
bash程式設計小問題!!

By Hedy
at 2008-09-01T14:51
at 2008-09-01T14:51
Ubuntu 下 firefox, terminal 當掉

By Kama
at 2008-09-01T05:56
at 2008-09-01T05:56
新手請教 關於套件安裝問題

By Xanthe
at 2008-09-01T03:04
at 2008-09-01T03:04
新手請教 關於套件安裝問題

By Elizabeth
at 2008-09-01T02:36
at 2008-09-01T02:36
Ubuntu 安裝時找不到硬碟

By Jake
at 2008-09-01T01:24
at 2008-09-01T01:24