How to print a new line in MS-DOS script?

I want to print the output of a program in MS-DOS, so I wrote a .bat file that says:

cls
ruby foo.rb

But the output - as it appears on my command line - looks like this:

c:\workspace>ruby foo.rb
foo output
c:\workspace>

I wanted to insert a new line into the output using MS-DOS because I don't want to pollute my Ruby code with anything unrelated to what the code should do.

The only commands in MS-DOS that look the way I want are type and print, but both are for printing files.

I tried to create a text file with two blank lines and output it using the "type" command, but it looks messy.

Any ideas would be appreciated.

+5
7

echo. .

, script :

@ECHO OFF
cls
echo.
ruby foo.rb
+24

:

@echo off
cls
echo.
ruby foo.rb
echo.

+4

4 ECHO., !

.

  • ECHO. ~ 10 , echo, ECHO.


  • echo ( ), ECHO. , , - .

?
.

echo+
echo=
echo;
echo,
echo:
echo(

- , , /? \\..\..\windows\system32\calc.exe.

ECHO<character>%variable%

echo=/?
echo;/?
echo,/?
echo:\\..\..\windows\system32\calc.exe

, ECHO( .
, , - .

+4

echo.
+3

echo, , MS-DOS:

echo.
+2

jeb. "echo (" ". , . , .

"echo" test.bat test.cmd, script:

@echo off
echo %time%
echo.
echo Hello, World
echo.
echo.
echo What time is it?
echo.
echo It Miller Time!
echo.
echo.
echo CHEERS!
echo.
echo %time%

. ? , "echo" .

"echo".

0,05 , "". - .

"". "echo (" .

0,01 , echo (".

, "echo" .

.

+1

, , , , .

If you want the result to be sent to another location, use dos "pipe" output.

ruby foo.rb > out.txt

outputs ruby ​​command output to out.txt file.

If you want to control the output, use ECHO.

@ECHO OFF/ON //turns off/on command output
ECHO "Blah" //writes "Blah" to the console.
ECHO. //writes a blank line to the console.
0
source

All Articles