Re: [問題] script 印出一百個*
※ 引述《RiverJackson (JACK)》之銘言:
: 請問一下
: for $a in a b c;then
: echo $a
: done
: 語法應該類似這樣 如果我想印出一到一千呢
: for $b in 1:1:100;then
: echo $a
: done
: 這樣寫應該是錯誤的 要怎麼寫呢~~~~
排一下版
==start==
declare -i i=1
while let "$i <= 1000" ;
do echo $i
let i=$i+1;
done;
==end==
附上 bash man page 節錄
declare [-afFirtx] [-p] [name[=value] ...]
-i The variable is treated as an integer; arithmetic evalua-
tion (see ARITHMETIC EVALUATION ) is performed when the
variable is assigned a value.
let arg [arg ...]
Each arg is an arithmetic expression to be evaluated (see ARITH-
METIC EVALUATION). If the last arg evaluates to 0, let returns
1; 0 is returned otherwise.
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.160.32.211
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 4 篇):
LinuxDev 近期熱門文章
PTT數位生活區 即時熱門文章