Featured

    Featured Posts

Redirecting input and output

You can redirect the input to a program from a file. You can also redirect the output of a program to a file. Redirections are done using symbols after the command. For example, to redirect the output of the ls command to the file ls_output.txt, you can use the following command:
linux output redirection
Note that the ls command didn’t output anything to the terminal. This is because we have redirected the output from the terminal to the file using the “>” operator. We have then displayed the content of the ls_output.txt file using the cat command.
Here is a list of all redirection symbols and their description:
linux redirection symbols
Here is a couple of examples.
To append the standard output to the file, use the >> operator:
linux append output
In the example above we have added the current date to the end of the ls_output.txt file.
For an example of the input redirection, we will use the mail command. This command can take a content of the file as standard input. For example, to mail the contents of the file ls_output.txt to the user bob, we can use the following command:
linux redirect input
author

Author Name

Author Description!

Get Free Email Updates to your Inbox!

Post a Comment

www.ccna.ma

yu
Powered by Blogger.

Translate

Copyright © Learn Linux Th3pro.xyz | Blogger Templates | Designed By Code TAOUSSI