shell的問題請教 - Linux

Vanessa avatar
By Vanessa
at 2011-07-07T17:59

Table of Contents

小弟在寫shell時會產生一些檔案
可是因為比對的關係,有些檔案會是空檔
於是小弟想再額外寫一段shell去刪除空檔

以下是我的程式段
執行後並不會刪除除空檔,想請教正確的寫法
# if file is null then delete
test -s $homedir/log_not_upload > /dev/null
if [ $? -eq 0 ]; then
rm $homedir/log_not_upload
fi

想請教該怎麼改才會刪除檔案
感謝

--

We must not confuse dissent with disloyalty!!

--
Tags: Linux

All Comments

Zenobia avatar
By Zenobia
at 2011-07-11T08:59
find . -type f -size 0 -exec ls {} \;
Annie avatar
By Annie
at 2011-07-15T04:27
呃. 為什麼不直接 test -s $file && rm $file
Dorothy avatar
By Dorothy
at 2011-07-19T12:17
還有,檔案有沒有空白行?
Elizabeth avatar
By Elizabeth
at 2011-07-23T15:42
你弄反:FILE exists and has a size greater than zero
Odelette avatar
By Odelette
at 2011-07-26T07:21
改: if [ -f $xxx ]; then test -s $xxx || rm $xxx; fi
Ula avatar
By Ula
at 2011-07-29T22:26
反了耶XD 不過不用test -f吧, 沒有東西,rm也不會怎樣

如何抓取矩陣的資料

Olive avatar
By Olive
at 2011-07-06T20:25
如果我資料格式如下 3 1 5 6 --andgt;第0列 1 2 4 6 1 2 1 1 如果要抓第一列第三行(也就是6) 請問有什麼指令可以做到嘛? 還是直接寫一支程式比較快XD? 謝謝各位板友的指教 -- ~宅男的四個徵兆~ ∠□ ○ ! ...

有沒有這麼燙的筆電?

Sierra Rose avatar
By Sierra Rose
at 2011-07-06T12:28
我幫ASUS筆電裝了fedora 15,突然想看一下這台筆電的溫度 (之前沒看過),結果: [rootatXXX ~]# sensors acpitz-virtual-0 Adapter: Virtual device temp1: +94.0°C (crit = +98.0°C) nou ...

串流伺服器

Annie avatar
By Annie
at 2011-07-06T00:53
想架一個串流伺服器 影像檔是固定的檔案 大部分是avi檔 有沒有可能有現成的solution是可以把這些avi轉換成像youtube一樣的flash動畫 然後透過HTTP或其他協定來進行服務的? - ...

請問RHEL 6 有可用的Ntop rpm套件嗎?

Lydia avatar
By Lydia
at 2011-07-05T17:29
compile ntop from scratch 應該不會太難吧? http://phorum.study-area.org/index.php/topic,65180.msg323138.html#msg323138 這邊有講怎麼裝 ntop-4.0.3 不過我到現在還沒試出怎麼在solaris 10 ...

CentOS 5.5死當

Isla avatar
By Isla
at 2011-07-05T14:46
最近因應口試潮,lab的server也常常over loading 四核心的電腦常常跑到loading超過10 不過近三個月來server常常死當,機率約一禮拜發生一次 查看了cron的記錄檔發現當機時間都不固定(有設定一個cron每五分鐘跑一次抓loading) message上面也都沒有任何相關的 ...