file counts 計算 請教 - Linux

By Zanna
at 2018-04-18T00:29
at 2018-04-18T00:29
Table of Contents
請教一個迴圈問題
我要寫一個迴圈去比對 /usr/data 資料夾內
第一層目錄底下,任何一個資料夾, 內的檔案數量, 達於36500筆,
必須要記錄 log 並且mail通知
我寫了下面寫法,但是不work
#! /bin/sh
file=`ls -ald /usr/data/*|awk '{print $9}'`
for i in $file
do
file_count=`ls $i|wc -l|sed 's/ //g'` #計算每個資料夾檔案數
if [ $file_count -gt 36500 ];then
echo "$i is $file_count " > /tmp/log.txt #匯出某一個資料夾檔案數量到log
#希望顯示某個資料夾,count數是多少
echo "$i is $file_count" | mailx -s "file too big" [email protected]
fi
done
我覺得上面寫法在讀取每個資料夾 分別計算count 數寫錯
請問這應該要如何修改
--
Tags:
Linux
All Comments

By Brianna
at 2018-04-19T07:02
at 2018-04-19T07:02

By Tracy
at 2018-04-24T06:35
at 2018-04-24T06:35

By Frederica
at 2018-04-26T16:54
at 2018-04-26T16:54

By Emma
at 2018-04-29T03:40
at 2018-04-29T03:40

By Catherine
at 2018-04-30T06:08
at 2018-04-30T06:08

By Lucy
at 2018-05-04T17:25
at 2018-05-04T17:25

By Mary
at 2018-05-06T22:51
at 2018-05-06T22:51
Related Posts
新手在Lubuntu安裝軟體問題,請益

By Freda
at 2018-04-17T20:12
at 2018-04-17T20:12
新手在Lubuntu安裝軟體問題,請益

By Puput
at 2018-04-16T16:38
at 2018-04-16T16:38
新手在Lubuntu安裝軟體問題,請益

By Necoo
at 2018-04-15T15:10
at 2018-04-15T15:10
新手在Lubuntu安裝軟體問題,請益

By George
at 2018-04-15T13:48
at 2018-04-15T13:48
Arch桌面環境設定

By Joseph
at 2018-04-15T04:52
at 2018-04-15T04:52