How to avoid grep warning messages

Hi All,
When i try to grep for a patern in an directory, I am getting warning like "No such file or directory". Anyway script is working as expected. but i need to avoid this warning message.
Pass="`find . -type f | xargs grep 'test result - pass' | wc -l`"
grep: ./results/6052278-1-717520-HFR_QFTS_ALL.__taskid2.isis_test.Beginning: No such file or directory
grep: ISIS: No such file or directory
grep: config: No such file or directory
grep: load: No such file or directory
grep: ./results/6052278-1-717520-HFR_QFTS_ALL.__taskid2.isis_test.Beginning: No such file or directory
grep: interface%2Fbasic: No such file or directory
grep: pings%2Ftraceroute%2Fcontroller: No such file or directory
grep: check: No such file or directory

Thanks,
Parkkavan

Redirect the output of stderr to /dev/null:

find . -type f | xargs grep 'test result - pass' 2>/dev/null | wc -l

Thanks Franklin. It works fine..

Can you tellme "2" mean in 2>/dev/null.

Thanks,
Parkkavan

2 by default is the file pointer for the error messages, 1 is that for stand output. Both go to screen by default. In this case you redirect error to /dev/null so you don't see them.

Thanks wireonfire for the explanation. :slight_smile:

Regards,
Parkkavan

You're seeing this because the find command passes the filenames it finds as a list of words separated by spaces. The problem is some of the files have spaces in the names. If you're on Linux or otherwise using GNU find & GNU xargs, you can use:

find . -type f -print0 | xargs -0 grep 'test result - pass' | wc -l

'print0' tells find to use \0 as the separator instead of space, and the -0 option to xargs tells it to accept \0 as the separator.