1753776 Members
7500 Online
108799 Solutions
New Discussion юеВ

2>&-

 
SOLVED
Go to solution
Jerome Salyers
Advisor

2>&-

hi,

i have the info on 2>&1 but this 2>&- is unclear to me... could someone please explain this to me, and maybe, if possible, explain (or point to) other examples of redirecting?

thanks

jerome
5 REPLIES 5
Trond Haugen
Honored Contributor

Re: 2>&-

There is no difference. Bothe '1' and '-' means standard out.

Regards,
Trond
Regards,
Trond Haugen
LinkedIn
Robert-Jan Goossens
Honored Contributor
Solution

Re: 2>&-

Hi Jerome,

Take a look at man remsh

example

remsh otherhost . .profile 2>&- \; command

The 2>&- throws away error messages generated by executing .profile when stdin and stdout are not a terminal.

Robert-Jan.
Andreas Voss
Honored Contributor

Re: 2>&-

Hi,

if you use 2>&1 then stderr is redirected to stdout.

if you use 2>&- then stderr will be closed which means that no stderr messages will be written out.

You can read about this in the manual of ksh in the section Input/Output:

man ksh


Regads
Trond Haugen
Honored Contributor

Re: 2>&-

Sorry Jerome but I was too quick. '2>&-' means that the standard error is closed.

Regards,
Trond
Regards,
Trond Haugen
LinkedIn
Yogeeraj_1
Honored Contributor

Re: 2>&-

hi jerome,

concerning "other examples of redirecting"

Please note that there is also the "tee" which is often used..

E.g.
L-9iAS: d05/9iAS>who |tee -a yd.txt
deg pts/ta Jan 29 07:58
jeanfr pts/tb Jan 29 15:34
glenda pts/tc Jan 29 12:16
L-9iAS: d05/9iAS>more yd.txt
deg pts/ta Jan 29 07:58
jeanfr pts/tb Jan 29 15:34
glenda pts/tc Jan 29 12:16
L-9iAS: d05/9iAS>

Write a list of users to the screen and also append the list to the file yd.txt

see man tee

Hope this helps!
Regards
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)