Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to put a new line character in an echo line in a batch file? [duplicate]

Tags:

Is it possible to put a new line character in an echo line in a batch file?

Basically I want to be able to do the equivalent of:

echo Hello\nWorld

You can do this easily enough in Linux, but I can't work out how to do it in Windows.

like image 828
Benj Avatar asked Nov 12 '09 10:11

Benj


People also ask

How can I echo a newline in a batch file?

To create a blank line in a batch file, add an open bracket or period immediately after the echo command with no space, as shown below. Adding @echo off at the beginning of the batch file turns off the echo and does not show each of the commands. @echo off echo There will be a blank line below. echo.

How do I batch echo multiple lines?

To add multiple lines to a file with echo, use the -e option and separate each line with \n. When you use the -e option, it tells echo to evaluate backslash characters such as \n for new line. If you cat the file, you will realize that each entry is added on a new line immediately after the existing content.

How do I echo a new line in Windows?

You can insert an invisible ascii chr(255) on a separate line which will force a blank new line. Hold down the [alt] key and press 255 on the keypad. this inserts chr(255) which is a blank square. i.e. "echo (alt+255)" You can only use the keypad not the numbers at the top of the querty keyboard!


1 Answers

echo. prints an empty line.

Example:

echo Hello
echo.
echo world

prints

Hello

world
like image 71
Blind Trevor Avatar answered Sep 19 '22 17:09

Blind Trevor