SEARCH

The How-To Geek Forums Have Migrated to Discourse

How-To Geek Forums / Geek Stuff

(Solved) - New line in batch using only one "echo"

(4 posts)
  • Started 1 year ago by needshelp
  • Latest reply from needshelp
  • Topic Viewed 432 times

needshelp
needshelp
Posts: 158

Hey there again!

So I need to be able to write two lines using only one echo in batch.
sort of like \n in java. I also read about using Alt+1+0 but that didn't work.

here's an example of what i am trying to do.

-----------------------------------------------------------------------------
@echo off
set test=This should be the first line. [some command] This should be the second line.
goto next

:next
echo %test%
pause
--------------------------------------------------------------------------------------

Output should be:

This should be the first line.
This should be the second line.
Click any key to continue...

Posted 1 year ago
Top
 
needshelp
needshelp
Posts: 158

For the record I also tried

-----------------------------------------------------------------------------
@echo off
set test=This should be the first line. echo. echo This should be the second line.
goto next

:next
echo %test%
pause
--------------------------------------------------------------------------------------

Which didn't work.

Posted 1 year ago
Top
 
Xhi
Xhi
Posts: 6298

Well if you can use echo twice in the same line, then this works...

Echo line1 && echo line2

Accepted Answer · Posted 1 year ago
Top
 
needshelp
needshelp
Posts: 158

Woo! that worked! thank you Xhi.

Posted 1 year ago
Top
 



Topic Closed

This topic has been closed to new replies.