我正在尝试查找所有者具有可执行权限的文件数量。我正在这样做,但出现错误
cmd> ls -la /myScript.sh
myScript.sh 如下
z=0
while read line
do
#for total lines read
#wc -l
#total unique user
#top three largest directory
#for total executables
for i in $(echo $line | sed -n '/^-rwx/p'| wc -l)
do
#echo $i #process in this if-then filter out 0 and sum non-zero
if [$i -ne 0]
then
echo $i
# $(z=z+i)
fi
done
done
echo "Total executable files by owner $z";
答案1
考虑使用find
和wc
。
阅读他们的手册。你的脚本可以在一行中完成:
find . -type f -perm -u=x | wc -l