Count the number of executable files in bash

前端 未结 2 1609
逝去的感伤
逝去的感伤 2021-01-29 13:07

I have seen a lot of answers about this subject but I don\'t want to do this using find. I have written this but something not working:

function Cou         


        
2条回答
  •  走了就别回头了
    2021-01-29 13:40

    To count the number of executable (like the title says)

     count=0 
     for file in yourdir/*; do 
         if [ -x $file ]; then 
             count=$((count+1)); 
         fi; 
     done; 
     echo "total ${count}"
    

    To count folders, just change the -x test with -d

提交回复
热议问题