使用shell tee 命令顯示及儲存標準輸出及標準錯誤輸出

tolywang發表於2012-02-11
 
$ vi  wq.sh 
 
#!/bin/bash
path=`pwd`
cd ..
echo "current path = $path"
path2="/u01"
echo  $path2 
$aa="aa"

$  sh wq.sh  2>&1 | tee  1.log   
current patch = /data/d1/sit/applsit
/u01
wq.sh[7]: =aa: not found.
 
檢視1.log檔案,可以看到執行正常的和出錯的資訊都顯示在log檔案中。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/35489/viewspace-716061/,如需轉載,請註明出處,否則將追究法律責任。

相關文章