Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.unix.shell > #4452
| From | Ivan Shmakov <oneingray@gmail.com> |
|---|---|
| Newsgroups | comp.unix.shell |
| Subject | Re: n>&m |
| Date | 2012-03-14 13:14 +0700 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <86haxrbtfq.fsf@gray.siamics.net> (permalink) |
| References | <9a3dee23-7370-493d-8846-340b76c31a9e@gw9g2000vbb.googlegroups.com> |
>>>>> Andre Aitken <andre.aitken.a@gmail.com> writes: > In a shell > program n>&m > Does this mean, send the output that "program" is writing to > descriptor n to the *current* location of calling shell's descriptor > m? Not quite. Consider, e. g.: $ LC_ALL=C cmp -- /dev/null /dev/zero 5>&1 2>&5 1>/dev/null cmp: EOF on /dev/null $ There, 5>&1 redirects command's &5 to Shell's &1 (e. g., the terminal), then 1>&5 redirects command's &1 to the /just redirected/ &5, and thus to Shell's &1. After that, 1>/dev/null allows us to discard command's &1, so that we could see it clearly that the gratuitous error message we've asked for was indeed propagated to the Shell's &1. > This is what I gather from the way examples are ordered (that is, > they always put 2>&1 after > file , and some explicitly say never to > switch order). Note that although against the convention, 2>FILE >&2 does effectively the same. -- FSF associate member #7257
Back to comp.unix.shell | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
n>&m Andre Aitken <andre.aitken.a@gmail.com> - 2012-03-13 22:16 -0700
Re: n>&m Ivan Shmakov <oneingray@gmail.com> - 2012-03-14 13:14 +0700
Re: n>&m Andre Aitken <andre.aitken.a@gmail.com> - 2012-03-22 19:43 -0700
Re: n>&m Barry Margolin <barmar@alum.mit.edu> - 2012-03-23 02:21 -0500
csiph-web