When working with files processing, there might be needed to add text at the end of the file without deleting its content. This operation also known as text appending. This tutorial provides 2 methods how to that on Windows.
Method 1 - CMD
The >>
redirection operator can be used to append text to the end of a file without overwriting its content:
echo First line>> test.txt
echo Second line>> test.txt
File will be created if not exist.
Method 2 - PowerShell
In PowerShell, the Add-Content
allows to append text to the end of a file.
Add-Content test.txt "First line"
Add-Content test.txt "Second line"
If file not exist, it will be created.
Leave a Comment
Cancel reply