Shell script問題請教 - Linux

Table of Contents

最近在寫一個Linux shell script.

主要是去判斷檔案資料夾是否存在,執行程式,並取得回傳值。

內容大致為:

if [ -d /home/ddd ]; then
rm -r /home/ddd/*
printf "Delete items"
else
....
printf "create folders"
fi
...
...

當我執行shell時,可以看到printf的這些資訊顯示在console上。

想請問是否有什麼指令可以"在console看到這些資訊"

並將這些資訊存入另外一個Log file?

謝謝大家的幫忙。



--

All Comments

Valerie avatarValerie2012-04-07
tee(1)
Ina avatarIna2012-04-10
不太懂樓上的意思是?
Damian avatarDamian2012-04-11
./東西.sh | tee 紀錄檔名稱
Oliver avatarOliver2012-04-14
./your_script 2>&1 | tee log.txt