Redirection in Shell-Unix/linux

0 0
Read Time:46 Second

Redirection is a function common to most command-line interpreters, including various unix shells that can redirect standard streams to user specified locations.

UNIX STANDARD I/O Streams

0- stdin (Standard input)

1- stdout (Standard output)

2- stderr (standard error)

 

 

 

Redirecting standard input and standard output

simple redirection to a file:  $command  > file

redirection &  appending to a file:   $command >> file

Redirecting to and from the standard file handles

eg: $ command  2> file

executes the command & redirects standard error to file.

Merging of standard error into standard output can be obtained by

eg: $ find / -name .profile > results 2>&1

 

Redirect to multiple outputs

The standard command “tee” can be used to redirect output from a command to several destinations

eg: $  ls -lrt | tee xyz

this redirects the file list output to both “standard output” and “file xyz”.

 

 

 

 

Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleppy
Sleppy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%

Leave a Reply

Your email address will not be published. Required fields are marked *