find
with no “action” applies its default -print
action, which outputs the full file name to standard output. Errors go to standard error.
The pipe operator only redirects standard output; so only “correct” file names are sent to less
, everything else goes to standard error, which is your terminal. less
also writes to your terminal, so you’ll initially see both file names and errors on your screen; but when you scroll up in less
(or invoke any other action which causes it to update the screen), the errors will be overwritten by less
’s updates since less
is only aware of the input it’s seen from find
’s standard output.
To page through the complete output in less
, you need to redirect standard error too:
find / -name foo 2>&1 | less
To completely ignore errors, redirect it to the bit bucket instead:
find / -name foo 2>/dev/null | less
find / -name foo 2>/dev/null
does the same thing, butless
is useful when the output is long. Well.