I saw @
is used in such contexts:
@echo off
@echo start eclipse.exe
What does @
mean here?
It means not to output the respective command. Compare the following two batch files:
@echo foo
and
echo foo
The former has only foo
as output while the latter prints
H:\Stuff>echo foo
foo
(here, at least). As can be seen the command that is run is visible, too.
echo off
will turn this off for the complete batch file. However, the echo off
call itself would still be visible. Which is why you see @echo off
in the beginning of batch files. Turn off command echoing and don't echo the command turning it off.
Removing that line (or commenting it out) is often a helpful debugging tool in more complex batch files as you can see what is run prior to an error message.
It means "don't echo the command to standard output".
Rather strangely,
echo off
will send echo off
to the output! So,
@echo off
sets this automatic echo behaviour off - and stops it for all future commands, too.
Source: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/batch.mspx?mfr=true
By default, a batch file will display its command as it runs. The purpose of this first command which @echo off is to turn off this display. The command "echo off" turns off the display for the whole script, except for the "echo off" command itself. The "at" sign "@" in front makes the command apply to itself as well.
The @
disables echo for that one command. Without it, the echo start eclipse.exe
line would print both the intended start eclipse.exe
and the echo start eclipse.exe
line.
The echo off
turns off the by-default command echoing.
So @echo off
silently turns off command echoing, and only output the batch author intended to be written is actually written.
It inherits the meaning from DOS. @:
In DOS version 3.3 and later, hides the echo of a batch command. Any output generated by the command is echoed.
Without it, you could turn off command echoing using the echo off
command, but that command would be echoed first.
Another useful time to include @ is when you use FOR
in the command line. For example:
FOR %F IN (*.*) DO ECHO %F
Previous line show for every file: the command prompt, the ECHO
command, and the result of ECHO
command. This way:
FOR %F IN (*.*) DO @ECHO %F
Just the result of ECHO
command is shown.
In batch file:
https://i.stack.imgur.com/h8un3.png
2 echo off(solo)=> the “echo off” shows in the command line
https://i.stack.imgur.com/40pth.png
https://i.stack.imgur.com/GhxkA.png
https://i.stack.imgur.com/IUxl6.png
See, echo off(solo), means no output in the command line, but itself shows; @echo off(solo), means no output in the command line, neither itself;
you can include @ in a 'scriptBlock' like this:
@(
echo don't echoed
hostname
)
echo echoed
and especially do not do that :)
for %%a in ("@") do %%~aecho %%~a
Success story sharing