• Source
    1. #
    2. #Write a script to display the name of all executable files in the given directory
    3. #
    4. clear
    5. echo -n "Enter name of the directory :"
    6. read directory
    7.  
    8. if [ ! -d $directory ]
    9. then
    10. echo "Directory not exist"
    11. else
    12. count=0
    13. echo "Files with executable rights are"
    14. #ONE SOLULTION IS
    15. # for i in `ls $directory`
    16. # do
    17. # if [ -x $directory/$i ]
    18. # then
    19. # echo $i
    20. # fi
    21. # count=$(echo count + 1 | bc -l)
    22. # done
    23. for i in $(find $directory -type f -perm +111)
    24. do
    25. echo $i
    26. count=$(echo count + 1 | bc -l)
    27. done
    28. if [ $count -eq 0 ]
    29. then
    30. echo "No files found with executable rights"
    31. fi
    32. fi
    33.