#!/bin/bash</code>
$dirName
counter=0
prefix=`pwd`
for file in `ls $prefix/$1`;
do
counter=`expr $counter + 1`
if [ -s $prefix/$file ]; then
echo $file "is not empty"
fi
done
echo "There are $counter files in "$prefix/$1" we need to process"
执行
./countfile.sh 文件夹名
该脚本可以得到当前目录下某个文件夹内的非空文件的文件名以及文件总数,这里不包含隐藏文件,若要得到隐藏文件可以修改ls命令
|