1. 程式人生 > >shell腳本學習心得

shell腳本學習心得

ror bak shell腳本學習 定向 bsp not 一個 spa basename

如果腳本錯誤退出,一個好習慣是顯示腳本名並將之定向到標準錯誤中。用戶應該知道產生錯誤的腳本名

#!/bin/sh
# ifcp.sh
if cp myfile myfile.bak > /dev/null 2>&1; then
                echo "good copy"
else
                echo "`basename $0`: error could not copy the file" >&2
fi

shell腳本學習心得