Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

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
share|improve this answer
    
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?

share|improve this answer

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
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .