Often you may want to use Bash to add a newline to the end of a file.
You can use the following syntax with echo to do so:
echo >> teams.txt
This particular example will add a newline to the end of the file named teams.txt.
Note that the >> command is used to append content to an existing file.
By using the echo statement with no text, a newline is simply added to the end of the file.
The following example shows how to use this syntax in practice.
Example: Use Bash to Add a newline to End of a File
Suppose that we have a file in our current directory named teams.txt that contains the names of various basketball teams.
We can use the cat command to view the contents of this file:

We can see that the file ends with the text Boston Celtics as the last line.
Suppose that we would like to add a newline to the end of this file so that the last line is a blank line.
We can use the following syntax to do so:
echo >> teams.txt
The following screenshot shows how to use this syntax in practice:

Notice that when we use the cat command again to view the contents of the file we can see that a newline has been added to the end of the file so that the last line is a blank line.
All other content in the file has remained unchanged.
Feel free to replace teams.txt with the name of your own file.
Related Tutorials
The following tutorials explain how to perform other common tasks in Bash:
Bash: How to Insert Text at the Beginning of File
Bash: How to Display Both Head and Tail of File
Bash: How to Select Random Lines from a File
