中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-18 01:39
47,814 topics / 349,907 posts / today 4 new / 48,259 members
DOS疑难解答 & 问题讨论 (解答室) » Special symbols in DOS
Printable Version  999 / 4
Floor1 Jneny Posted 2006-04-02 15:59
高级用户 Posts 318 Credits 686
Special symbols in MSDOS have different functions and meanings.
For example > , >>, <, &, |.
EG:MORE < type command.com
So when can these special symbols be used, and what do the other symbols mean???
Floor2 Climbing Posted 2006-04-02 21:28
铂金会员 Posts 2,753 Credits 6,962 From 河北保定
For this question and the previous one, either search the old threads or use Google.
Floor3 Jneny Posted 2006-04-06 13:56
高级用户 Posts 318 Credits 686
Oh, I'll take a look then
Floor4 JonePeng Posted 2006-04-07 01:08
金牌会员 Posts 1,883 Credits 4,562 From 广东广州
Floor5 bagpipe Posted 2006-04-07 09:33
银牌会员 Posts 425 Credits 1,144 From 北京
These are all the basic functions of symbols in cmd, maybe they'll be useful to you
By using conditional processing symbols, you can run multiple commands from a single command line or script. When multiple commands are run through conditional processing symbols, the command to the right of the conditional processing symbol works according to the result of the command to the left of the conditional processing symbol. For example, you may want to run a new command only if the previous command failed. Or, you may want to run a new command only if the previous command succeeded.
You can use the special characters listed in the table below to pass multiple commands.
Character Syntax Definition
& [...] command1 & command2 Used to separate multiple commands on one command line. Cmd.exe runs the first command, then runs the second command.
&& [...] command1 && command2 Used to run the command after the && symbol only if the command before the && symbol succeeds. Cmd.exe runs the first command, and then runs the second command only if the first command ran successfully.
|| [...] command1 || command2 Used to run the command after the || symbol only if the command before the || symbol fails. Cmd.exe runs the first command, and then runs the second command only if the first command did not run successfully (received an error code greater than zero).
( ) [...] (command1 & command2) Used to group or nest multiple commands.
; 或者 , command1 parameter1;parameter2 Used to separate command parameters.
Note
· The ampersand (&), pipe symbol (|), and parentheses () are special characters. If you pass them as parameters, you must put an escape character (^) or quotation marks before them.
· If a command completes successfully, it returns a zero (0) exit code or returns no exit code at all


> create a file
>> append to the end of a file
@ prefix character. Means that when executing, this line is not displayed in cmd; you can use echo off to turn off display
^ leading character for special symbols ( > < &). The first one just displays aaa, the second one outputs to file bbb
echo 123456 ^> aaa
echo 1231231 > bbb
() contains commands
(echo aa & echo bb)
, default separator symbol, same as a space.
; comment, means what follows is a comment
: label function
│ pipe operation
; when the command is the same, this symbol can separate different targets with ; but the execution result does not change. If an error occurs during execution, it only returns an error report but the program will still continue executing

First of all, @ is not a command, but a special marker in DOS batch processing, used only to suppress command-line echo. Below are some special markers you may see in the DOS command line or in batch processing:
CR(0D) command line terminator
Escape(1B) ANSI escape character introducer
Space(20) commonly used parameter delimiter
Tab(09) ; = uncommon parameter delimiters
+ COPY command file concatenation symbol
* ? file wildcards
"" string delimiter
| command pipe symbol
< > >> file redirection symbols
@ command-line echo suppression symbol
/ parameter switch introducer
: batch label introducer
% batch variable introducer


Second, :: can indeed serve as a rem comment, and is more concise and effective; but there are two points to note:
First, besides ::, any line beginning with : is treated as a label in batch processing, and everything after it is directly ignored. Just to distinguish it from a normal label, it is recommended to use a label that goto cannot recognize, that is, put a non-alphanumeric special symbol immediately after :.
Second, unlike rem, a line after :: will not be echoed during execution no matter whether command-line echo is turned on with echo on, because the command interpreter does not regard it as a valid command line. From this point of view, rem is more suitable than :: in some situations; in addition, rem can be used in config.sys files.



The following usage can also be used:
if exist command
device refers to devices that have been loaded in the DOS system; under win98 these usually include:
AUX, PRN, CON, NUL
COM1, COM2, COM3, COM4
LPT1, LPT2, LPT3, LPT4
XMSXXXX0, EMMXXXX0
A: B: C: ...,
CLOCK$, CONFIG$, DblBuff$, IFS$HLP$
The specific contents will vary slightly depending on the hardware and software environment. When using these device names, the following three points must be ensured:
1. The device really exists (except for devices virtualized by software)
2. The device driver has been loaded (standard devices such as aux, prn, etc. are defined by the system by default)
3. The device is ready (mainly refers to a: b: ..., com1..., lpt1..., etc.)
You can use the command mem/d | find "device" /i to inspect the devices loaded in your system
Also, in DOS systems, devices are also regarded as a kind of special file, and files can also be called character devices; because both devices and files are managed by handles, and a handle is the name, similar to a filename, except that a handle is not used for disk management, but for memory management. So-called device loading means allocating a referable handle for it in memory.
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023