
所有者による実行権限を持つファイルの数を調べようとしています。これを実行していますが、エラーが発生します
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
。
マニュアルを読んでください。スクリプトは 1 行で実行できます。
find . -type f -perm -u=x | wc -l