Skip to main content

Stack Exchange Network

Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
Asked
Viewed 5k times
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
    –  fixit7
    2022-09-13 02:15:23 +00:00
    Commented Sep 13, 2022 at 2:15
  • @fixit7 Are you sure they are executable then? What is their mode (e.g. 755)?
    forest
    –  forest
    2022-09-13 02:16:07 +00:00
    Commented Sep 13, 2022 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
    –  fixit7
    2022-09-13 02:16:58 +00:00
    Commented Sep 13, 2022 at 2:16
  • @fixit7 I don't know. Can you post the entire output, including the command you used?
    forest
    –  forest
    2022-09-13 02:29:04 +00:00
    Commented Sep 13, 2022 at 2:29
  • 2
    @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
    –  JoL
    2022-09-14 06:14:02 +00:00
    Commented Sep 14, 2022 at 6:14

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.