May 08, 2005

写了一个统计一堆文件总大小的script

使用方法 mycount.sh "*.ext"
没有处理目录,懒了

bash-2.05b$ cat ~/bin/mycount.sh
#!/bin/sh
total=0

list=`ls $1`
for item in $list
do
size=`ls -l $item|awk '{print $5}'`
total=`expr $total + $size`
done

echo $total

Posted by hufey at May 8, 2005 05:36 PM
Comments

我是一棵搞不定的大白菜 :)

Posted by: alex at May 9, 2005 04:09 PM

我一直记不住awk的写法

btw 你是厨子?

Posted by: hufey at May 9, 2005 03:35 PM

du -sk *.ext|awk '{sum += $1 }; END { print sum }'

Posted by: alex at May 9, 2005 03:12 PM
Post a comment









Remember personal info?