<s>
In	O
computing	O
,	O
redirection	B-Device
is	O
a	O
form	O
of	O
interprocess	B-Operating_System
communication	I-Operating_System
,	O
and	O
is	O
a	O
function	O
common	O
to	O
most	O
command-line	O
interpreters	O
,	O
including	O
the	O
various	O
Unix	B-Application
shells	I-Application
that	O
can	O
redirect	O
standard	B-Operating_System
streams	I-Operating_System
to	O
user-specified	O
locations	O
.	O
</s>
<s>
In	O
Unix-like	B-Operating_System
operating	I-Operating_System
systems	I-Operating_System
,	O
programs	O
do	O
redirection	B-Device
with	O
the	O
system	B-Operating_System
call	I-Operating_System
,	O
or	O
its	O
less-flexible	O
but	O
higher-level	O
stdio	B-Operating_System
analogues	O
,	O
and	O
.	O
</s>
<s>
Redirection	B-Device
is	O
usually	O
implemented	O
by	O
placing	O
certain	O
characters	O
between	O
commands	B-Application
.	O
</s>
<s>
Typically	O
,	O
the	O
syntax	B-Application
of	O
these	O
characters	O
is	O
as	O
follows	O
,	O
using	O
< to redirect input, and >	O
to	O
redirect	O
output	O
.	O
</s>
<s>
This	O
will	O
clobber	B-General_Concept
any	O
existing	O
data	O
in	O
.	O
</s>
<s>
Using	O
executes	O
,	O
with	O
as	O
the	O
source	O
of	O
input	O
,	O
as	O
opposed	O
to	O
the	O
keyboard	B-Device
,	O
which	O
is	O
the	O
usual	O
source	O
for	O
standard	O
input	O
.	O
</s>
<s>
To	O
append	O
output	O
to	O
the	O
end	O
of	O
the	O
file	O
,	O
rather	O
than	O
clobbering	B-General_Concept
it	O
,	O
the	O
>>	O
operator	O
is	O
used	O
:	O
.	O
</s>
<s>
executes	O
,	O
using	O
its	O
output	O
as	O
the	O
input	O
for	O
(	O
commonly	O
called	O
piping	B-Operating_System
,	O
with	O
the	O
"	O
|	O
"	O
character	O
being	O
known	O
as	O
the	O
"	O
pipe	O
"	O
)	O
.	O
</s>
<s>
The	O
two	O
programs	O
performing	O
the	O
commands	B-Application
may	O
run	O
in	O
parallel	O
with	O
the	O
only	O
storage	O
space	O
being	O
working	O
buffers	O
(	O
Linux	O
allows	O
up	O
to	O
64K	O
for	O
each	O
buffer	O
)	O
plus	O
whatever	O
work	O
space	O
each	O
command	O
's	O
processing	O
requires	O
.	O
</s>
<s>
As	O
an	O
example	O
,	O
although	O
DOS	O
allows	O
the	O
"	O
pipe	O
"	O
syntax	B-Application
,	O
it	O
employs	O
this	O
second	O
approach	O
.	O
</s>
<s>
A	O
good	O
example	O
for	O
command	O
piping	B-Operating_System
is	O
combining	O
echo	B-Application
with	O
another	O
command	O
to	O
achieve	O
something	O
interactive	O
in	O
a	O
non-interactive	O
shell	O
,	O
e.g.	O
</s>
<s>
This	O
runs	O
the	O
ftp	B-Protocol
client	O
with	O
input	O
,	O
press	O
,	O
then	O
.	O
</s>
<s>
In	O
casual	O
use	O
,	O
the	O
initial	O
step	O
of	O
a	O
pipeline	B-Operating_System
is	O
often	O
cat	O
or	O
echo	B-Application
,	O
reading	O
from	O
a	O
file	O
or	O
string	O
.	O
</s>
<s>
This	O
can	O
often	O
be	O
replaced	O
by	O
input	O
indirection	O
or	O
a	O
here	O
string	O
,	O
and	O
use	O
of	O
cat	O
and	O
piping	B-Operating_System
rather	O
than	O
input	O
redirection	B-Device
is	O
known	O
as	O
useless	O
use	O
of	O
cat	O
.	O
</s>
<s>
For	O
example	O
,	O
the	O
following	O
commands	B-Application
:	O
</s>
<s>
As	O
echo	B-Application
is	O
often	O
a	O
shell-internal	O
command	O
,	O
its	O
use	O
is	O
not	O
as	O
criticized	O
as	O
cat	O
,	O
which	O
is	O
an	O
external	O
command	O
.	O
</s>
<s>
In	O
Unix	B-Application
shells	I-Application
derived	O
from	O
the	O
original	O
Bourne	B-Device
shell	I-Device
,	O
the	O
first	O
two	O
actions	O
can	O
be	O
further	O
modified	O
by	O
placing	O
a	O
number	O
(	O
the	O
file	B-Application
descriptor	I-Application
)	O
immediately	O
before	O
the	O
character	O
;	O
this	O
will	O
affect	O
which	O
stream	O
is	O
used	O
for	O
the	O
redirection	B-Device
.	O
</s>
<s>
In	O
shells	O
derived	O
from	O
csh	B-Operating_System
(	O
the	O
C	B-Operating_System
shell	I-Operating_System
)	O
,	O
the	O
syntax	B-Application
instead	O
appends	O
the	O
(	O
ampersand	O
)	O
character	O
to	O
the	O
redirect	O
characters	O
,	O
thus	O
achieving	O
a	O
similar	O
result	O
.	O
</s>
<s>
Another	O
useful	O
capability	O
is	O
to	O
redirect	O
one	O
standard	O
file	B-Application
handle	I-Application
to	O
another	O
.	O
</s>
<s>
Executed	O
without	O
redirection	B-Device
,	O
it	O
will	O
output	O
hits	O
to	O
stdout	O
and	O
errors	O
(	O
e.g.	O
</s>
<s>
A	O
simplified	O
but	O
non-POSIX	O
conforming	O
form	O
of	O
the	O
command	O
,	O
is	O
(	O
not	O
available	O
in	O
Bourne	B-Device
Shell	I-Device
prior	O
to	O
version	O
4	O
,	O
final	O
release	O
,	O
or	O
in	O
the	O
standard	O
shell	O
Debian	B-Operating_System
Almquist	I-Operating_System
shell	I-Operating_System
used	O
in	O
Debian/Ubuntu	O
)	O
:	O
or	O
.	O
</s>
<s>
The	O
rule	O
is	O
that	O
any	O
redirection	B-Device
sets	O
the	O
handle	O
to	O
the	O
output	O
stream	O
independently	O
.	O
</s>
<s>
The	O
redirection	B-Device
and	O
piping	B-Operating_System
tokens	O
can	O
be	O
chained	O
together	O
to	O
create	O
complex	O
commands	B-Application
.	O
</s>
<s>
This	O
type	O
of	O
construction	O
is	O
used	O
very	O
commonly	O
in	O
shell	B-Language
scripts	I-Language
and	O
batch	O
files	O
.	O
</s>
