I'm trying to empty all the Trash bin files located in /nfshome/*/.local/share/Trash/files

But I can't seem to find the proper find command to do it:

I can find files and dirs within the Trash directory:

$ sudo find /nfshome/*/.local/share/Trash/
... plus lots more

But I don't get what I would expect if I drill down one more into the files directory:

$ sudo find /nfshome/*/.local/share/Trash/files/

Only one result. The result happens to be the user I am currently logged in with. Why doesn't it find the rest of the traash files? FOr example, these two from the first search?


It's your shell who expands * before find starts. The shell runs without sudo. To match many /nfshome/*/.local/share/Trash/ it needs to access many share directories. It apparently can, in the first case it works.

But to match many /nfshome/*/.local/share/Trash/files/ the shell needs to access many Trash directories. Hypothesis: the shell is permitted only to access one Trash. It has no permission to know there are files/ in other Trash directories.

In the first case find got many Trash directories and descended having all the permissions because of sudo; so it could find all files/. In the second case find got just one directory named files/ as an argument.

We could test if it's about not having read permission, execute permission or both. These details cannot change my main point: your shell is not permitted to "detect" some directories, sudo find … is permitted to find them all.

  • Can you give an example how to solve the problem? Jun 11 '20 at 4:28

As @KamilMaciorowski says


run a bash as root.

sudo bash -c 'find /nfshome/*/.local/share/Trash/'

Do it in find

Tell find the base directories, and use -path etc.

E.g. (not quite right, as it will find .local in any sub-directory)

sudo find /home -path "*/.local/share/Trash/*"

Better. Convert to a regex (to do the same as the one above).

sudo find /home -regex ".*/[.]local/share/Trash/.*"

Then anchor to a home directory

sudo find /home -regex "/home/[^/]+/[.]local/share/Trash/.*"
  • can you provide an explicit example using -path? does that replace -name? Jun 11 '20 at 4:30
  • sudo 'bash -c find /nfshome/*/.local/share/Trash/' => command not found; all your other three in find work, thank you. Jun 11 '20 at 20:00
  • Sorry the quote got put in the wrong place (fixed). Jun 12 '20 at 18:00

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.