Receive all updates via Facebook. Just Click the Like Button Below

Input - Output redirection in Shell Scripts

Using shell scripts, we can redirect
- the output of a command to a file
or
- redirect an output file as an input to other commands.

There are mainly 3 types of redirection. They are >,>>,<

1

Input - Output redirections in Linux Shell Scripting

2

1. >

Example:
ls > ls-file

The above command will redirect the output of the " ls " to the file " ls-file ".
If the file " ls-file " already exist, it will be overwritten. Here you will loose the existing data.

2. >>

Example:
date >> ls-file

The output of the date command will be appended to the file " ls-file ".
In this case you will not loose any data. The new data gets added to the end of the file.

3. <

Example:
cat < ls-file

This redirection symbol takes input from a file.
In the above example the cat command takes the input from the file " ls-file " and displays the "ls-file" content.

3

Related posts:

Advertise here

picture picture

Follow us

picture

- Tech-Tutorials twitter.com/techcuriosity

Like us

About Techcuriosity

I am Telson, the webmaster of Techcuriosity.com and through this site, I share my knowledge and curiosities in the Tech World.


What We Offer

  • What is ..?
  • How to ..?
  • Difference between ..?
  • How .. works?
  • Get in Touch

    techcuriosity@gmail.com
    UK : +44 77 33 890 678

    picture picture

    Our Partners

  • Website Design Dubai
  • SEO Link Exchange
  • picture

    picture