From: Stachu 'Dozzie' K. on
On 01.03.2006, yusufm <yusufm(a)gmail.com> wrote:
> ls > dirlist 2>&1
>
> ls 2>&1 > dirlist

What do you want to do with these two commands? I see no question...

--
Feel free to correct my English
Stanislaw Klekot
From: yusufm on
I want to know what the difference between the two are. Specifically
the impact of the order of the redirection directives.

Thanks.


Stachu 'Dozzie' K. wrote:
> On 01.03.2006, yusufm <yusufm(a)gmail.com> wrote:
> > ls > dirlist 2>&1
> >
> > ls 2>&1 > dirlist
>
> What do you want to do with these two commands? I see no question...
>
> --
> Feel free to correct my English
> Stanislaw Klekot

From: yusufm on
In the second case:

stderr redirected to stdout
then, stdout redirected to dirlist

so shouldn't stderr now go to dirlist?





Janis Papanagnou wrote:
> yusufm wrote:
> > I want to know what the difference between the two are. Specifically
> > the impact of the order of the redirection directives.
>
> Don't top-post! Read http://cfaj.freeshell.org/google/ for details.
>
> >>On 01.03.2006, yusufm <yusufm(a)gmail.com> wrote:
> >>
> >>>ls > dirlist 2>&1
> >>>
> >>>ls 2>&1 > dirlist
>
> You'll see the effect if, instead of ls, you use a command that prints
> output to stdout and stderr.
>
> I use a compound command (and ksh syntax) to illustrate that...
>
> $ { print -u1 "stdout" ; print -u2 "stderr" ;} >dirlist 2>&1
> # no output
> # stdout redirected to the file and stderr to the same as stdout
> $ cat dirlist
> stdout
> stderr
> $ { print -u1 "stdout" ; print -u2 "stderr" ;} 2>&1 >dirlist
> # stderr redirected to tty and stdout to the file
> stderr
> $ cat dirlist
> stdout
>
>
> Janis

From: yusufm on
Thanks to everyone who responded. A lot of old CS courses came flooding
back and I have now seen the light! :)




Lew Pitcher wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> yusufm wrote:
> > In the second case:
> >
> > stderr redirected to stdout
> > then, stdout redirected to dirlist
> >
> > so shouldn't stderr now go to dirlist?
>
> Nope.
>
> The 2nd argument redirected stdout away from where-ever it was before, and to
> the 'dirlist'. However, nothing changed stderr, so it stays where it is,
> pointing to where-ever stdout /used to/ point to.
>
>
>
> - --
> Lew Pitcher
>
> Master Codewright & JOAT-in-training | GPG public key available on request
> Registered Linux User #112576 (http://counter.li.org/)
> Slackware - Because I know what I'm doing.
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.7 (GNU/Linux)
>
> iD8DBQFEBlQLagVFX4UWr64RAtjiAJ9kSKFYYb7wX89gmS07U3JBgXnKkACeNxy/
> vdPm7NV9ru3wgdIVsGPYj9o=
> =3Lbf
> -----END PGP SIGNATURE-----