Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BASH - counting the number of executable files

Im trying to find the executables files and their total in a folder,its showing but the total is not this is my code below,can someone help me out were i am making mistakes,i am just a newbie trying to learn some bash scripting hope this is the right way of doing it thanks

#!/bin/bash
To="home/magie/d2"
cd "$To"
find . -type f -perm 755

if 
   find . -type f -perm 755
then
 echo | echo wc -l
fi
like image 373
kryticrecte Avatar asked Dec 28 '22 07:12

kryticrecte


1 Answers

If you want to find all the executable files then use this command:

find home/magie/d2 -type f -perm -u+rx | wc -l

OR

find home/magie/d2 -type f -perm +111 | wc -l

All the answers here are finding files with permission 755 only however keep in mind even 744 or 700 are also executable files by the user.

like image 155
anubhava Avatar answered Jan 09 '23 05:01

anubhava