標(biāo)題: while 的問題 [打印本頁] 作者: czh8030 時(shí)間: 2003-12-05 16:27 標(biāo)題: while 的問題 while :
do
......
done
中while后加一個(gè):是表示無限循環(huán)的意思,冒號(hào):是干什么的呀!作者: c1l2d3 時(shí)間: 2003-12-05 16:30 標(biāo)題: while 的問題 應(yīng)是表示true 始終為真吧!不知對(duì)不作者: bjgirl 時(shí)間: 2003-12-05 16:32 標(biāo)題: while 的問題 null作者: r2007 時(shí)間: 2003-12-05 16:41 標(biāo)題: while 的問題 相當(dāng)于匯編中的NOP語句作者: r2007 時(shí)間: 2003-12-05 16:57 標(biāo)題: while 的問題 : null command. This is the shell equivalent of a "NOP" (no op, a do−nothing operation). It may be considered a synonym for the shell builtin true. The ":" command is a itself a Bash builtin, and its exit status is "true" (0).
<Advanced Bash−Scripting Guide>[/code]作者: admirer 時(shí)間: 2003-12-05 17:48 標(biāo)題: while 的問題 while后面需要一個(gè)邏輯表達(dá)式,“:”即表示一個(gè)邏輯“真”亦即“true”作者: Mercury_cn 時(shí)間: 2003-12-05 20:35 標(biāo)題: while 的問題 我習(xí)慣用 while true作者: bjgirl 時(shí)間: 2003-12-05 20:56 標(biāo)題: while 的問題 [quote]原帖由 "Mercury_cn"]我習(xí)慣用 while true[/quote 發(fā)表:
:冒號(hào)一般在shell中的作用同null,表示什么都不作(前提條件為true),如:
if ls;then
:/null #什么都不做!
else
....
fi
當(dāng)條件總為真true的時(shí)候,while后再加:就是多余的~~作者: 網(wǎng)中人 時(shí)間: 2003-12-06 01:00 標(biāo)題: while 的問題 true 是個(gè)外部命令,
: 是 shell 的內(nèi)部命令...
在調(diào)用上,我喜歡用 :
(尤其是懶人.... ^_^ )作者: bjgirl 時(shí)間: 2003-12-06 01:07 標(biāo)題: while 的問題 $type true
true is a shell builtin
$type :
: is a special shell builtin
$whereis true
true: /bin/true /usr/share/man/man1/true.1.gz
$file /bin/true
/bin/true: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), stripped