Appending with >>
Adding to the end.
Often you don't want to replace a file. You want to add to the end of it, like adding an item to a shopping list. For that, use two greater than signs.

- Don't replace
- Add to the end
- Two greater than signs
Adding to a list
Our notes file has three items. Echo, buy bread, followed by two greater than signs, and the file name, adds a fourth line, at the end. Do it again, and a fifth line appears. Nothing is lost.
cat notes.txt Buy milk Call Mum Learn Linux echo "Buy bread" >> notes.txt echo "Water plants" >> notes.txt cat notes.txt Buy milk Call Mum Learn Linux Buy bread Water plants
A simple diary
Appending is perfect for logs and diaries. Here we add a line with the date, and then a line describing what we did. Each time you run these, the file grows, and keeps its history.
date >> diary.txt echo "Learned redirection" >> diary.txt cat diary.txt Mon Jan 5 09:00:00 UTC 2026 Learned redirection
One sign or two
Here's the difference to remember. One greater than sign means write, and replaces everything. Two greater than signs mean append, and add to the end. When you're unsure, use two. The worst that can happen, is an extra line.
>
- Write
- Replaces the file
- Starts fresh
>>
- Append
- Adds to the end
- Keeps what's there
Summary
Two greater than signs add to the end of a file, and keep what's already there. Next, editing files properly, with a text editor in the terminal.
Key takeaways- cmd >> file
- Adds to the end
- > replaces, >> appends