Re: Unix File Descriptors In Bash
- From: Janis Papanagnou <janis_papanagnou@xxxxxxxxxxx>
- Date: Wed, 22 Sep 2010 20:45:24 +0200
On 22/09/10 20:10, pk wrote:
[...]
iii) What does |& do (they state it is equivalent to 2>&, but I do not
know what this does).
This is present in bash 4, and basically doing
somecommand |& grep foo
is the same as doing
somecommand 2>&1 | grep foo
What that does is to redirect stdout and stderr to the same place. So you
are basically sending both stdout and stderr down the pipe in both cases.
There is an equivalent operator to do the same for files, so
somecommand &> file
is the same as
somecommand >file 2>&1
The operator can have two forms: &> and >&, of which the manual says the
first one is preferred (I would have thought the second one is preferred, to
make it consistent with |&, but no).
This is what I thought as well when I read the respective line of your
posting. Isn't there any rationale provided with that recommendation?
Janis
.
- Follow-Ups:
- Re: Unix File Descriptors In Bash
- From: Barry Margolin
- Re: Unix File Descriptors In Bash
- From: pk
- Re: Unix File Descriptors In Bash
- References:
- Unix File Descriptors In Bash
- From: gkl
- Re: Unix File Descriptors In Bash
- From: pk
- Unix File Descriptors In Bash
- Prev by Date: Re: executing a getopts option (if specified) always first
- Next by Date: Re: Unix File Descriptors In Bash
- Previous by thread: Re: Unix File Descriptors In Bash
- Next by thread: Re: Unix File Descriptors In Bash
- Index(es):
Relevant Pages
|