farmer-logo.gif (14959 bytes) cshell-logo.gif (19625 bytes)
ch-4.gif (10100 bytes)
main-b.gif (271 bytes)


mail.gif (2925 bytes)

4-2-9 status 執行狀態變數

變數 status 乃是用以顯示最近的指令執行狀態。執行成功狀態為 0;失敗狀態為 1。本變數常運用於 shell 程式設計中判斷上一個指令的執行情況。譬如用指令 grep 在資料檔中找尋某個字串的狀態。

% grep akira /etc/passwd
akira:lv8u/EYmXK5kU:101:100:SYMBAD USER:/home1/akira:/bin/csh
% echo $status
0
% cd aaaa
aaaa: No such file or directory
/home1/akira> !e
echo $status
1

b-line.gif (2092 bytes)