On Sat, Aug 27, 2011 at 8:38 AM, ashwin kesavan <[email protected]> wrote:
> On 19 August 2011 18:57, Prasanna Venkadesh <[email protected]> wrote:
>> On Fri, Aug 19, 2011 at 5:23 PM, Sathia S <[email protected]> wrote:
>>>
>>> >  espeak 'hi' > /dev/null 2>&1
>>
>>
>> Thanks all for helping me out. The above thing works perfect. and can anyone
>> give me explanation of what it does? One is it redirects to /dev/null and
>> what does 2>&1 really does?
>

I will explain.

$ ls > /dev/null 2>&1

is the Bourne/ksh syntax for redirecting both stdout and stderr to /dev/null

/dev/null is a construct to ignore output

This is the way it is told to the shell.

Redirect fd 1 to somewhere, then redirect fd 2 to fd 1( 2>&1)

The left hand side is without '&', say 1> /dev/null or 2>/dev/null

But the right hand side is written with an '&' to mean:

Instead of to the file foo in 2>foo, redirect to the fd with

2>&1

So this means

redirect fd 2 to fd 1

Instead if you write

2>1

it will redirect to a file called 1

-Girish

-- 
G3 Tech
Networking appliance company
web: http://g3tech.in  mail: [email protected]
_______________________________________________
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc

Reply via email to