歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> 關於Linux >> linux exit命令學習

linux exit命令學習

日期:2017/3/1 14:41:06   编辑:關於Linux
linux exit命令學習 linuxexitshell退出碼 exit命令有兩個作用: 1. 退出當前shell sh-# exit exit INIT: Entering runlevel: 3 2. 在shell script中直接退出,這樣我們寫shell scripts時就可以借助於特定的 退出碼來表示scripts的執行狀況。 sh-# touch /test_exit.sh sh-# cat /test_exit.sh #!/bin/sh exit 127 sh-# ls -l /test_exit.sh -rwxr-xr-x 1 root root 24 Jan 1 00:04 /test_exit.sh sh-# $? sh: 0: command not found sh-# /test_exit.sh sh-# $? sh: 127: command not found sh-# echo "exit 126" > /test_exit.sh sh-# cat /test_exit.sh exit 126 sh-# /test_exit.sh sh-# $? sh: 126: command not found sh-# vim sh: vim: command not found sh-# $? sh: 127: command not found 關於退出碼的約定: 通常0,表示命令執行成功; 非0,表示命令執行失敗。
Copyright © Linux教程網 All Rights Reserved