I have a directory, named data, with multiples files in it which have different types of permissions. I want to delete only the files that do not have any permissions, i.e shown as ---------- in ls -l. My guess is to use the find command, but I don't know where to start.

What one line command can do this ?


The find command you are looking for is this:

find /path/to/data -type f -perm 000 -delete

Caution: First run the above command without -delete to make sure that it lists the correct files.

  • -type f lists files only.
  • -perm 000 lists items without permissions only (000 is "no permissions" in octal mode).
  • -delete deletes the found items.

See man find for more options.


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.