Now we know how to overwrite a file’s contents, but what if we want to be able to add to a file without losing the original text? We can use the >> command!

$ cat deserts.txt >> forests.txt

>> takes the standard output of the command on the left and appends (adds) it to the file on the right.

Here, the output data of forests.txt will contain the original contents of forests.txt with the content of deserts.txt appended to it.



Use >> to append the contents of glaciers.txt to rivers.txt.


Use cat to view the contents of rivers.txt.

Notice that we see rivers and glaciers as output.

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?