China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-30 05:00
中国DOS联盟论坛 » DOS疑难解答 & 问题讨论 (解答室) » Special symbols in DOS View 950 Replies 4
Original Poster Posted 2006-04-02 15:59 ·  中国 江西 抚州 电信
高级用户
★★★
中國DOS聯盟常任參議员
Credits 686
Posts 318
Joined 2005-11-04 13:00
20-year member
UID 77577
Gender Male
Status Offline
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???
Floor 2 Posted 2006-04-02 21:28 ·  中国 河北 保定 移动
铂金会员
★★★★
网络独行侠
Credits 6,962
Posts 2,753
Joined 2003-04-16 00:00
23-year member
UID 1565
Gender Male
From 河北保定
Status Offline
For this question and the previous one, either search the old threads or use Google.
偶只喜欢回答那些标题和描述都很清晰的帖子!
如想解决问题,请认真学习“这个帖子”和“这个帖子”并努力遵守,如果可能,请告诉更多的人!
Floor 3 Posted 2006-04-06 13:56 ·  中国 江西 抚州 电信
高级用户
★★★
中國DOS聯盟常任參議员
Credits 686
Posts 318
Joined 2005-11-04 13:00
20-year member
UID 77577
Gender Male
Status Offline
Oh, I'll take a look then
Floor 4 Posted 2006-04-07 01:08 ·  中国 广东 广州 天河区 电信
金牌会员
★★★★
D◎$ Fαп
Credits 4,562
Posts 1,883
Joined 2004-01-19 00:00
22-year member
UID 15812
Gender Male
From 广东广州
Status Offline
----====≡≡≡≡ 我的至爱,永远是MSDOS!≡≡≡≡====----
Floor 5 Posted 2006-04-07 09:33 ·  中国 北京 顺义区 联通
银牌会员
★★★
DOS联盟捡破烂的
Credits 1,144
Posts 425
Joined 2005-10-20 00:00
20-year member
UID 43784
From 北京
Status Offline
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.
Forum Jump: