Is tar doing the right thing here?

Dan Nelson dnelson at allantgroup.com
Sun Aug 17 22:24:37 PDT 2003


In the last episode (Aug 18), Dan Langille said:
> Why is this message not being suppressed?
> 
> $ tar -czf test.tgz / 2>&1 > /dev/null
> tar: Removing leading `/' from member names

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-hackers mailing list