1

I'm a unix newb. I'm using find, but I'm getting too many results to fit on my screen since it's listing the permissions denied folders. I've tried piping it to more but that doesn't seem to have any effect. So, I have two questions:

  1. How can I filter out the folders to which I don't have access?
  2. How can I page the results of find - I can't get it to work with more.

Thanks

1
  • 4
    less is more.
    – Jeremy L
    Nov 2, 2009 at 20:08

3 Answers 3

8

to suppress permission denied errors, add 2>/dev/null to the end of your find statement

1

try with (if you're using sh, bash):

find . -name "foo" 2>&1 | more 
0

I am not sure why piping it to more does not work for you. But a simple solution would be to redirect the output to a file, and then page that. The following will redirect the standard output to a file, and the standard error will maintain the default, which is to display the error on the screen:

find . -iname '*something*' > myfile.out
more myfile.out

You will have to wait for find to complete to see everything though. If you want to get rid of those error messages entirely, and still have the non-error results go to that file:

find . -iname '*something*' > myfile.out 2> /dev/null

Each time you run this, myfile.out will be overwritten. This redirection is standard with the shell and can be used with most commands. Here is a little tutorial on redirection, it is worth learning.

The Other Examples:
With 2>&1 , standard error (stderr) is being redirected to stdout, so both end up getting piped to more. With 2> /dev/null you are sending them to special device which is basically a black hole ( aka the bit bucket). With *nix, devices are represented as a files.

You must log in to answer this question.

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