Redirect to /dev/null
Dan Nelson
dnelson at allantgroup.com
Fri Oct 10 13:42:04 PDT 2003
In the last episode (Oct 10), Max Clark said:
> What is the proper way to redirect output to /dev/null? I've been
> using the following in my crontab but output is still ending up in my
> mailbox.
>
> ... 2>&1 > /dev/null
I'm sure this is in a sh FAQ someplace:
What you did was dup fd1 onto fd2, then redirect fd1 to /dev/null:
fd1 -> stdout fd2 -> stderr
2>&1
fd1 -> stdout fd2 -> stdout
>/dev/null
fd1 -> /dev/null fd2 -> stdout
Swap the two redirects, so you redirect fd1 to /dev/null, then dup it
onto fd2:
fd1 -> stdout fd2 -> stderr
>/dev/null
fd1 -> /dev/null fd2 -> stdout
2>&1
fd1 -> /dev/null fd2 -> /dev/null
--
Dan Nelson
dnelson at allantgroup.com
More information about the freebsd-questions
mailing list