Come posso fare l'eco di un newline in un file batch?

Come puoi inserire un newline nell'output del tuo file batch?

Voglio fare qualcosa come

echo hello\nworld

Che produrrebbe un output:

hello
world

Utilizzare:

echo hello
echo.
echo world
Commentari (8)
Soluzione

echo hello & echo.world

Questo significa che potreste definire & echo. come una costante per un newline \n.

Commentari (17)

Ecco, create un file .bat con il seguente contenuto:

@echo off
REM Creating a Newline variable (the two blank lines are required!)
set NLM=^

set NL=^^^%NLM%%NLM%^%NLM%%NLM%
REM Example Usage:
echo There should be a newline%NL%inserted here.

echo.
pause

Dovresti vedere un output come il seguente:

There should be a newline
inserted here.

Press any key to continue . . .

Avete bisogno solo del codice tra le dichiarazioni REM, ovviamente.

Commentari (10)