-2

I am trying to find the number of files with executable permission by the owner. I am doing this but giving me error

cmd> ls -la /myScript.sh

myScript.sh is the following

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";
3
  • 1
    Read the manual page of the find command, look for the -executable flag.
    – dawud
    May 1, 2015 at 17:53
  • 1
    Homework problem? May 1, 2015 at 18:04
  • aren't many here are?
    – UnixUser
    May 5, 2015 at 10:39

1 Answer 1

3

Consider using find and wc.

Read their manuals. Your script can be done in one line:

find . -type f -perm -u=x | wc -l

Not the answer you're looking for? Browse other questions tagged .