WeCodeAcademy

Redirection: > and >>

Redirection sends output into a file instead of the screen. > creates or overwrites a file. >> appends to the end.

Examplebash
Open in editor »
/ $

Oops: the second > replaced "first". That is why > is dangerous on a file you care about. It works with any command, not just echo.

Examplebash
Open in editor »
/ $
Quick check

You want to add a line to the end of `notes.txt` without losing what is there. Which do you use?

Your turn: write the code

Write one into f.txt, then append two without losing one, then print the file.

Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.

Tip: use the left and right arrow keys to move between lessons.