A
A
Azat Kiberov2018-12-26 19:43:56
cmd/bat
Azat Kiberov, 2018-12-26 19:43:56

How to make a line break in a bat file?

There is the following bat file with code
for /l %%i in (1,1,10) do echo <? phpcode ?> >%%i.php
We need to make it create files like this
for /l %%i in (1,1,10) do echo
<?
phpcode
?> >%%i.php
But I tried it and it doesn't work.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vitaliy Orlov, 2018-12-26
@mbxngtgo

echo off
for /l %%i in (1,1,10) do (
    echo ^<^?php > %%i.php
    echo php code .. >> %%i.php
    echo ^?^>php >> %%i.php
)

The ^ sign = escapes special characters
If you need an empty string, you can do this echo. >> %%i.php(i.e. a dot at the end of echo)
In the first command, use > to overwrite the file when called again, unlike >> which adds data without overwriting

M
Moskus, 2018-12-26
@Moskus

If the code is long, you will be tormented to echo it out. Put it in a separate file and redirect the type output for this file to the correct one, or concatenate with copy.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question