Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
370 views
in Technique[技术] by (71.8m points)

windows - What is the at sign (@) in a batch file and what does it do?

One remotely familiar with windows/dos batch scripting will recognize this line:

@echo off

For many-many days, I was happy with the sentiment that the @ is how echo off is meant to be written at the top of the batch and that's it.

However, recently I've came accross a line like this:

@php foo bar

and another line like this:

@call \networkfolderatch.bat

This reinforced my suspicion that @ has more to it than just echo mode switching. However @ is not listed in the Windows XP: Command-line reference A-Z which I try to use as a reference and thus I'm not sure how to find definitive information on this:

What is the @ sign in batch, what's the terminology for it, and what does it do?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

At symbol - @

The @ symbol tells the command processor to be less verbose; to only show the output of the command without showing it being executed or any prompts associated with the execution. When used it is prepended to the beginning of the command, it is not necessary to leave a space between the "@" and the command.

When "echo" is set to "off" it is not necessary to use "@" because setting "echo" to "off" causes this behavior to become automatic. "Echo" is usually set to "on" by default when the execution of a script begins. This is the reason "@echo off" is commonly used, to turn echo off without displaying the act of turning it off.

echo verbose
@echo less verbose
pause

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...