我正在嘗試查找所有者俱有可執行權限的檔案數量。我正在這樣做,但給了我一個錯誤
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