Reputation: 25581
I'm seeing double @
being used in some of our batch files, as in @@echo off
, and as far as I can see the initial first @
is redundant and I want to remove it to only have @echo off
.
Can I safely do that or does it have some hidden meaning I don't know about?
Upvotes: 1
Views: 641
Reputation:
@
has the effect to suppress the repetition of the executed commands, including the command echo off/on
and cmd
does not care how many times it is used:
The effect of:
@echo off
ping localhost
ping google
echo test string
is exactly the same as:
@@@@@@@@echo off
ping localhost
ping google
echo test string
and
@ping localhost
@ping google
@echo test string
or even:
@(ping localhost
ping google
echo test string
)
so technically @@somecommand
simply suppresses repetition, then suppresses repetition even though it has no effect any longer as it was already suppressed.
So a single @
is fine.
Upvotes: 2
Reputation: 82247
One or more @
disables the echoing of the current command.
If the echo mode is already OFF, then the @
has no special effect anymore.
So to answer your question, yes you can remove the redundant @
, one is enough.
Upvotes: 4