Learn

How does redirection work?

$ echo "Hello" > hello.txt

The > command redirects the standard output to a file. Here, "Hello" is entered as the standard input, and is then redirected to the file hello.txt by > .

As a reminder, the cat command outputs the contents of a file to the terminal. When you type:

$ cat hello.txt

the contents of hello.txt are displayed.

Instructions

1.

Let’s try our first redirect!

In the terminal, type:

echo "Hello World" > hello.txt
2.

Then type:

cat hello.txt

You should see "Hello World" printed to the console.

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?