Shell 判斷命令是否順利結束功能
Shell 判斷命令是否順利結束功能,範例如下:
success_test.sh
#!/bin/bash #Filename: success_test.sh
CMD="ls -lt" status $CMD if [ $? -eq 0 ]; then printf "%s executed successfully" $CMD else printf "%s executed unsuccessfully" $CMD fi
printf "\n" |
參考出處:Linux Shell 腳本攻略 P 25
沒有留言:
張貼留言