Is there a way of specifying multiline strings in batch in a way similar to heredoc in unix shells. Something similar to:
cat <<EOF > out.txt
bla
bla
..
EOF
The idea is to create a customized file from a template file..
Is there a way of specifying multiline strings in batch in a way similar to heredoc in unix shells. Something similar to:
cat <<EOF > out.txt
bla
bla
..
EOF
The idea is to create a customized file from a template file..
Not as far as I know.
The closest I know of is
> out.txt (
@echo.bla
@echo.bla
...
)
(@
prevents the command shell itself from printing the commands it's running, and echo.
allows you to start a line with a space.)
Yes, very possible. ^ is the literal escape character, just put it before your newline. In this example, I put the additional newline in as well so that it is properly printed in the file:
@echo off
echo foo ^
this is ^
a multiline ^
echo > out.txt
Output:
E:\>type out.txt
foo
this is
a multiline
echo
E:\>
This is even easier, and closely resembles cat << EOF > out.txt:
C:\>copy con out.txt
This is my first line of text.
This is my last line of text.
^Z
1 file(s) copied.
Output looks like this:
C:\>type out.txt
This is my first line of text.
This is my last line of text.
(copy con + out.txt, type your input, followed by Ctrl-Z and file is copied)
COPY CON means "copy from the console" (accept user input)