Linux Bash Input, Output and Redirect – POFTUT

Linux Bash Input, Output and Redirect

[rps-include post=6835]

Linux Bash have different ways to run command and get output of the command or redirect the output. In this tutorial we will look different ways to redirect commands output.

Writing Multiple Commands Same Line

Command line can be terminated with ; to write commands same line

In this example first clean command runs and after the execution ends what ever the command result is second command ls runs.

Redirect one command output to other command

To redirect one command output to the other command use |. | named as pipe. The standard output is redirected. In this example we run ls command which will print file and directory names in working directory. By using pipe we redirect ls output into sort command as input. sort as name suggests used to sorting alphabetically.

Check Previous Command Exit Status

When commands are chained together commands exit status which means the result of the command is important. For example copy a folder and change directory into new folder may chained together. If the the first command cannot be completed there is no need to run second command.

[rps-include post=6835]

LEARN MORE  How To Pause and Resume Powershell and Cmd Scripts In Windows With Examples?

Leave a Reply

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