I sometimes would do
grep -ri foo .
but in some node_modules, it could have some links to places that don't exist. So I can do a
grep -ri foo . 2>&-
grep -ri foo . 2> /dev/null
but sometimes it is difficult to remember. Is it possible to write an alias so that
grep -ri foo . | discarderr
can work? I think it might be difficult to do because only the stdout is passed to
discarderr. There probably is no way to pass both stderr and stdout to
discarderr and have
discarderr discard the error, such as
alias discarderr='cat 2> /dev/null'
Is there any way to do it, or maybe by a function but it probably looks a bit awkward if it is something like
discarderr(grep -ri foo .)?
It seems grep has a
-s that can silence the error message. But what about a general solution for other commands?