How to Use @ in Batch Script
We primarily use @echo off
at the beginning of the Batch Script. This article will discuss what @echo off
means and the purpose of using @
on a Batch Script using necessary examples and explanations.
Use of @
in Batch Script
The at
sign can be included in the script, denoted by the symbol @
. It is placed at the front of the command, which makes the command apply to itself.
The @
sign suppresses the output of the corresponding command in the Batch Script.
Use the @echo off
in Batch Script
We can use two commands with @echo
. These are @echo off
and @echo on
.
These keywords are used to enable or disable default displays on the screen. But by default, ECHO
is always in ON
mode.
Let’s see some examples for the @echo off
and echo off
commands to see their difference.
Example 1:
@echo off
The above code will turn off the command echoing silently, and that will only show the output the author intended. This command will only turn off the default automatic command echo behavior for the script.
Example 2:
echo off
The above code will only turn off the default command echoing for the whole script. The above code will turn off the command echoing silently, and that will only show the output the author intended.
But both examples will provide the same output.
Generally, the @echo
and echo
can provide the same output. Let’s have a look at the below example.
@echo This is the text...
echo This is the text...
If you run both of the command shown above, you will see that both will provide the same output as below.
Output:
This is the text...
Remember, all methods discussed here are written using Batch Script and will only work in a Windows CMD environment.
Aminul Is an Expert Technical Writer and Full-Stack Developer. He has hands-on working experience on numerous Developer Platforms and SAAS startups. He is highly skilled in numerous Programming languages and Frameworks. He can write professional technical articles like Reviews, Programming, Documentation, SOP, User manual, Whitepaper, etc.
LinkedIn