What is a good use of the output redirection operator ">>"?

Question

In this lesson, we are introduced to the >> operator which appends information to a file. That is, if file1.txt and file2.txt are two files

cat file1.txt >> file2.txt

adds the contents of file1.txt to the end of file2.txt. How do we benefit from using this operation?

Answer

The >> operator is a helpful extension of the normal standard output redirection provided by >. It is not uncommon for the data we want to store to be the result of multiple separate operations. Because of this, it is helpful to be able to build a file gradually: adding a first part, then adding another part at a later time, and so on like this without a necessary end. The ability to append these new parts with the existing file is the provided functionality of >>.

12 Likes