Learn
Redirection
Introduction

Up until now, we have run commands in the command line and received a stream of output in the terminal. In this lesson, we’ll focus on input and output (I/O) redirection.

Through redirection you can direct the input and output of a command to and from other files and programs, and chain commands together in a pipeline. Let’s try it out.

You can reference the filesystem for this lesson here.

What happens when you type this command?

$ echo "Hello" Hello

The echo command accepts the string “Hello” as standard input, and echoes the string “Hello” back to the terminal as standard output.

Let’s learn more about standard input, standard output, and standard error:

  1. standard input, abbreviated as stdin, is information inputted into the terminal through the keyboard or input device.

  2. standard output, abbreviated as stdout, is the information outputted after a process is run.

  3. standard error, abbreviated as stderr, is an error message outputted by a failed process.

Redirection reroutes standard input, standard output, and standard error to or from a different location.

Instructions

Move on to the next exercise when you’re ready to start redirecting!

Folder Icon

Sign up to start coding

Already have an account?