temp.sh:
exit 1
test.sh:
trap “echo ‘[ERROR] 執行function: testfunction 失敗’;exit” ERR
sh ./temp.sh
執行./test.sh,腳本會調用trap語句,顯示“[ERROR] 執行function: testfunction 失敗”並退出。
temp.sh:
exit 1
test.sh:
trap “echo ‘[ERROR] 執行function: testfunction 失敗’;exit” ERR
sh ./temp.sh
執行./test.sh,腳本會調用trap語句,顯示“[ERROR] 執行function: testfunction 失敗”並退出。
先是確定傳入的參數是一個,然後如果成立,然後利用ls -lR遍歷循環所有的文件夾下的文件,然後用grep選擇出其中的文件,其中^是開頭的意思,-是文件的意思,然後wc統計