我有一个批处理文件,例如:test.bat
,其中只有一个命令:
echo Hello
然后我运行它:
D:\cmd\test.bat
然后输出结果:
//output begin
-- This is a blank line, I don't want this
D:\cmd\echo Hello -- This is not what I want
Hello -- I only want to print this line
-- This is a blank line, I don't want neither.
//output end
我只想打印批处理文件中运行的命令输出,这里是echo
命令。
但是,有两个空白行,一个位于结果的开头,另一个位于结果的末尾。结果中的D:\cmd\echo Hello
既不是我想要的。
我该怎么办?任何帮助都会很棒,提前谢谢。
答案 0 :(得分:2)
刚刚放
@echo off
在批处理文件的第一行。这将阻止命令在运行时输出(就像在@之前添加命令一样),因此它会消除所有打扰你的行。
取自http://ss64.com/nt/echo.html
Type ECHO without parameters to display the current echo setting (ON or OFF).
In most batch files you will want ECHO OFF, turning it ON can be useful when
debugging a problematic batch script.
In a batch file, the @ symbol is the same as ECHO OFF applied to the current line only.
Normally a command is executed and takes effect from the next line onwards, @
is a rare example of a command that takes effect immediately.