I'm trying to find a directory with this command:

find /users/dan/ -name 'Prams' -type d

I see a huge amount of 'No such file or directory' output. Is there a way to make find shut up if it doesn't find anything?

migrated from stackoverflow.com Feb 25 '12 at 1:27

This question came from our site for professional and enthusiast programmers.

  • this worked for me: find /users/dan/ -name 'Prams' -type d | tee log – nulltorpedo Feb 25 '12 at 1:41
  • 1
    the pipe without ampersand only outputs std output. If it was |& log, it will print those errors as well. – nulltorpedo Feb 25 '12 at 1:42

Try this:

find /users/dan/ -name 'Prams' -type d 2>/dev/null
  • it says: find:paths must precede expression. I am running linux 2.6.9-67.0.7 – nulltorpedo Feb 25 '12 at 1:32
  • which flavor: can you run uname -a – Book Of Zeus Feb 25 '12 at 1:38
  • Linux machine-3 2.6.9-67.0.7.ELsmp #1 SMP Wed Feb 27 04:47:23 EST 2008 x86_64 x86_64 x86_64 GNU/Linux – nulltorpedo Feb 25 '12 at 1:40
  • this worked for me: find /users/dan/ -name 'Prams' -type d | tee log – nulltorpedo Feb 25 '12 at 1:40
  • interesting, this didn't work for me – Book Of Zeus Feb 25 '12 at 1:42

You can suppress the STDERR output:

find /users/dan/ -name 'Prams' -type d 2> /dev/null

Or you can use find to show all directories and filter its output with grep:

find /users/dan -type d | grep "Prams"

The find command won't print "no such file or directory" if the search path (/users/dan, in this case) exists, even if there are no matches. Are you sure this directory exists?

His syntax is correct if indeed /users/dan/ < exists in the first place!

There should be no 'No such file or directory' outputs in the first place.

find $HOME -name 'Prams' -type d

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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