3

I'm trying to execute the following command: find . -name ".[ch]" | xargs grep -in pattern > file

There are some errors that are printed on stderr because a few files are not found. How can I redirect stdout to a file and stderr to /dev/null/ in the same command?

This command didn't work: find . -name ".[ch]" | xargs grep -in pattern 1> file 2> /dev/null/

The error message: ksh: /dev/null/: cannot create [Is a directory]

Can anyone tell me how I can do this?

Cheers, VSN

1 Answer 1

5

You typed /dev/null/ where it should be /dev/null !

find . -name ".[ch]" | xargs grep -in pattern 1> file 2> /dev/null

should work...

2
  • I feel really silly. Yeah, that worked... 0_0 Thanks a lot, sincerely! :)
    – VSN
    Nov 19, 2012 at 13:41
  • This kind of things happens even to the best ones among us. :) Happy I could help you.
    – Orabîg
    Nov 19, 2012 at 13:43

You must log in to answer this question.

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