#!/bin/bash
cd /home/a //切换到要统计文件数目的目录
fcnt=0dcnt=0frcnt=0fwcnt=0fxcnt=0for file in *do if [ -f $file ];then let fcnt+=1 if [ -r $file ];then let frcnt+=1 fi if [ -w $file ];then let fwcnt+=1 fi if [ -x $file ];then let fxcnt+=1 fi elif [ -d $file ];then let dcnt+=1 fidoneecho "There are $fcnt files in $PWD"echo -e "\tThere are $frcnt readable files in $PWD"echo -e "\tThere are $fwcnt writeable files in $PWD"echo -e "\tThere are $fxcnt executeable files in $PWD"echo "There are $dcnt directories in $PWD"
本文介绍了一个使用Bash脚本统计指定目录下文件总数及具备读、写、执行权限的文件数量的方法。此外,该脚本还统计了目录的数量。
1361

被折叠的 条评论
为什么被折叠?



