PIPING AND REDIRECTION IN LINUX

WHAT IS REDIRECTION?

Normally a command executing in the terminal shows it’s output on the terminal screen. Instead of that, if we could be able to print those output details to a file, it would be great. This what we known as Redirection. Redirecting the output of a command to a file instead to the terminal screen.

HOW TO REDIRECT?

  • > – Greater than sign is used to redirect data to a file.

20

21

  • >> – Two greater than signs are used to append data to a file.

22

  • < – Less than sign is used to get data from a file to the terminal.

23

WHAT IS PIPING?

In the above examples we saw that how to put the output to a file and how to get the input from a file. Now let’s see how to give the output of one command to another command. This is known as piping.

HOW TO DO PIPING?

  • | – Using this symbol in between two commands, we can redirect the output of first command to the second command as the input.

24

We can combine multiple commands using piping as well.

25

Also we can combine piping and redirection together as well.

26

27

Piping and Redirection is a much more advanced and helpful topic regarding LINUX. Hope you got clear idea about piping and redirection. Hope to see you soon with another interesting topic. Thank You!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s