Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to append an empty line in a text file using the command line?

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?

like image 350
Arunachalam Avatar asked Mar 31 '10 16:03

Arunachalam


1 Answers

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).

like image 53
Michael Myers Avatar answered Oct 15 '22 03:10

Michael Myers