Explain how Windows batch newline variable hack works

Viewed 36959

Can someone please explain how this works?

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

emits:

There should be a newline
inserted here.

from How can you echo a newline in batch files?

2 Answers
Related