Unix Pipe And Redirection

standard input output - Unix Pipe And Redirection

Standard Input/Output:

Standard input output and pipes
image source:-http://images.slideplayer.com

Linux operating system uses different types of input/output devices like keyboard, mouse, monitor, printer etc. It accepts the input and transfers a data to the system for processing. The standard input/output device managed by the operating system and use standard input files to manage the data and its related instructions. Unix operating system controls each information in the form of files. There are different files are used to manage input/output related statements like standard input, standard output, and standard error.

1. File description:

A file descriptor is an abstract indicator for excessing the file from particular location Linux system use these files to manage the input/output related processing and also control the networking instructions. A bash shell manages TCP and UDP to manage the port of network host using file description. It uses zero, 1 and 2 to represent the standard input, standard output, standard errors respectively. The file descriptor read the standard files from the particular directory in Linux operating system.


The Linux system also manages errors in the form of standard input/output files. The operators help to transfer the between the files and execute multiple commands together.

1. Input re-direction operator:

It is an input re-direction operator that define with left chevron < that read the input from the file and executes a particular command.


It is a command that display number of lines, number of character and number of words from the file. We use-l for the line -c for a character -w for word.

wc∅<opt>∅<file name>





2. Redirecting output to a file:

Linux operating system allows an operator to redirect the output in a particular file it means we can create the copy of the particular file it means we can create the copy of particular file content. We use right chevron > to read the content from the file and redirect the output in particular existing file.

cat∅<file name>∅<opt>∅<file name>

cat anna> Kanna

Combined Re-Direction:

The input and output re-direction is used to process the data from standard input and output. Linux system allows us to combined both operators together to get the input and return output also.


1. Standard Error:

The Linux system uses shell to interpret the commands then transfer to the kernel for execution. This system also generates an error at the time of execution with the help of output re-direction operator we can re-direct the output of command prompt at the particular file. We use >> this operator to switch the output of standard error into the particular file.

dog anna↵

dog anna>>Kanna↵

cat Kanna↵

cat<anna>tanna dog ann 2>Kanna↵

Re-directing Stroup To A Program:

Linux system allows us to manage the standard input/output operations using particular operator. An operator pipe is used to execute the command on the base of given instructions. Pipe symbol gets the input from a particular command and executes another command also. It means we can execute >> command together.

ls abc|wc<anna↵

Combining Output And Error:

Linux system manages the standard input-output operations using re-direction operator. It also manages the standard error through the operator.

1. Redirecting all outputs:

The standard output helps us to re-direct the multiple outputs in a particular file using re-direction operator. We use &> to re-direct the all outputs to a particular file.

find-name anna&>Kanna↵

2. Combining output:

Linux system allows us to execute more than one command together and separate with the pipe symbol. We can also separate the similar command with

cal 2040: cal 2044:lpr↵

Re-Directing Multiple Target:

Linux system provides a method to manage the command and redirect the output into different files. A command TEE used to re-direct the output multiple outputs. We define the command and use pipe symbol (!) then TEE command with the file name for storing the data.

command!tee file1 file2 file3

date!tee abc xy

cat abc! tee x y z m↵

Re-Directing Input From A File:

The data are stored in the file the particular content is the standard input can read the content from the file as well as the standard input device. The input will be read from the file.

We can define the contents of multiple lines and save into the particular file. We use << to start the multiple lines for a file and use close to stopping the contents.

About the author


Add Comment

Click here to post a comment