7

i want to find all the files that are not executable. I know how to find executable files

find -executable

but I don't know how to do the negation of -executable

1 Answer 1

13

You can use ! as a negation for most flags, although you have to escape it in some shells:

find \! -executable

You can also use -not if you are using the GNU version, but it is not POSIX-compliant.

See find(1) for more information.

10
  • I used that on my bin directory and it listed my scripts as non-executable?@forest
    – fixit7
    Sep 13 at 2:15
  • @fixit7 Are you sure they are executable then? What is their mode (e.g. 755)?
    – forest
    Sep 13 at 2:16
  • But why did it list them? -rwxrwxr-x 1 andy andy 234 Apr 15 16:30 Tea.sh* -rwxrwxr-x 1 andy andy 58 Jun 15 2020 text2file.sh* @forest
    – fixit7
    Sep 13 at 2:16
  • @fixit7 I don't know. Can you post the entire output, including the command you used?
    – forest
    Sep 13 at 2:29
  • 1
    @fixit7 The paths should precede the predicate expression (e.g. find foo.sh bar.sh ! -executable). I wonder what find you're using if it didn't raise an error like GNU's does when putting paths after the condition.
    – JoL
    Sep 14 at 6:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.