( find -print0 | xargs -0 cat ) | wc -l
(from How to count all the lines of code in a directory recursively?) prints the total number of lines in all files in all subdirectories. But it also prints a bunch of lines like cat: ./x: Is a directory
.
I tried ( find -print0 | xargs -0 cat ) | wc -l &> /dev/null
(and also 2> /dev/null
and > /dev/null 2>&1
) but the messages are still printed to the shell.
Is it not possible to hide this output?
( find -type f -print0 | xargs -0 cat ) | wc -l
overcomes this problem, but I'm still curious why redirecting stderr doesn't work, and if there is a more general purpose way to hide errors from cat
.