我已经看到了很多关于这个主题的答案,但我不想使用
find
. 我已经写了这个,但有些东西不起作用:
function CountEx()
{
count=0
for file in `ls $1`
do
echo "file is $file"
if [ -x $file ]
then
count=`expr $count + 1`
fi
done
echo "The number of executable files in this dir is: $count"
}
while getopts x:d:c:h opt
do
case $opt in
x)CountEx $OPTARG;;
d)CountDir $OPTARG;;
c)Comp $OPTARG;;
h)help;;
*)echo "Please Use The -h Option to see help"
break;;
esac
done
我正在使用这个脚本,如下所示:
yaser.sh -x './..../...../.....'
shell 运行它,然后它输出:
The number of executable files in this dir is: 0
当此目录中有许多可执行文件时。