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.


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

Sign up to start coding

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?