How do I append an empty line in a text file using the command line?
echo hi >a.txt
echo >>a.txt
echo arun >>a.txt
Here the output comes as:
hi
echo on
arun
So how could I append an empty line? I want it to be like this:
hi
arun
When I added this line on code @echo off
, it said echo off
. How can it be done?
In the Windows command prompt, try:
echo.>> a.txt
Note that there is no space between echo
and .
; if there is one, it will output a dot. There is also no space between the .
and the >>
; anything in between would be output to the file, even whitespace characters.
See the Microsoft documentation for echo
.
If this were in bash, your first try would have been correct:
echo >> a.txt
But in Windows, the unqualified echo
command tests whether there is a command prompt or not (echo off
turns the prompt off and echo on
turns it back on).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With