Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I echo a newline in a batch file?

How can you you insert a newline from your batch file output?

I want to do something like:

echo hello\nworld 

Which would output:

hello world 
like image 224
Brian R. Bondy Avatar asked Sep 25 '08 11:09

Brian R. Bondy


People also ask

How do you go to a new line in CMD?

All you need to do is simply echo out the line with ALT-10 characters and then redirect it to con and it will work!

What is @echo off in batch script?

batch-file Echo @Echo off @echo off prevents the prompt and contents of the batch file from being displayed, so that only the output is visible. The @ makes the output of the echo off command hidden as well.

What is %% A in batch script?

Use double percent signs ( %% ) to carry out the for command within a batch file. Variables are case sensitive, and they must be represented with an alphabetical value such as %a, %b, or %c. ( <set> ) Required. Specifies one or more files, directories, or text strings, or a range of values on which to run the command.

What is %1 in a batch file?

When used in a command line, script, or batch file, %1 is used to represent a variable or matched string. For example, in a Microsoft batch file, %1 can print what is entered after the batch file name.


2 Answers

Use:

echo hello echo: echo world 
like image 74
Matt Lacey Avatar answered Nov 01 '22 07:11

Matt Lacey


echo hello & echo.world

This means you could define & echo. as a constant for a newline \n.

like image 44
Grimtron Avatar answered Nov 01 '22 08:11

Grimtron