0

I have this piece of code:

echo %ip_address%>%logfile%
echo %hostname%>>%logfile%
echo %duration%>>%logfile%

However, I would like to know if it possible to echo each variable on a separate line.

I have tried the following:

 echo %ip_address% && %hostname% && %duration%>c:\text.txt
 echo %ip_address% & echo.%hostname% & echo.%duration%>c:\text.txt

None of these work.

jonrsharpe
  • 99,167
  • 19
  • 183
  • 334
Arthor
  • 594
  • 2
  • 10
  • 34
  • 2
    Uhm, you're already writing them each on their own line ... – Joey Mar 27 '15 at 22:17
  • @Joey They are all going into the logfile and I wanted to know if you could echo with variables and
    .
    – Arthor Mar 27 '15 at 22:21
  • 1
    http://stackoverflow.com/a/269819/4158862 – SomethingDark Mar 27 '15 at 22:24
  • So the log file is a HTML file and you want to insert a `br` element? – Joey Mar 27 '15 at 22:32
  • @Joey No, not at all. It is a bat. I should has said new line. – Arthor Mar 27 '15 at 22:33
  • Then it still makes absolutely no sense. `echo` *already writes only a single line*, which means that with three `echo` statements you get three lines. – Joey Mar 27 '15 at 22:35
  • @Joey I agree, however echo %ip_address% & echo.%hostname% & echo.%duration%>c:\text.txt' this should work, right? – Arthor Mar 27 '15 at 22:36
  • 2
    Nope, it would print the value of `%ip_address%` and `%hostname%` to the screen, and only `%duration%` to the file. You need to use parentheses, if you want to redirect multiple commands at once – Joey Mar 27 '15 at 22:45

0 Answers0