中国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 23:04
47,814 topics / 349,908 posts / today 1 new / 48,259 members
其它操作系统综合讨论区 » Problems with Windows command symbols
Printable Version  25,510 / 126
Floor1 panhong1986 Posted 2006-10-28 23:46
初级用户 Posts 10 Credits 29
In the process of learning DOS, I found that when looking at some examples, many people often use unused symbols, and there are many changes. Sometimes I understand the commands, but I get stuck here on the symbols. Can you guys concentrate and explain these symbols? I hope it can be more comprehensive, or help me find a place to learn.. Thanks..


Modify the title to match the topic content. Original title: DOS Symbol Problem
——Administrator
Floor2 electronixtar Posted 2006-10-29 00:00
铂金会员 Posts 2,672 Credits 7,493
Floor3 panhong1986 Posted 2006-10-29 13:02
初级用户 Posts 10 Credits 29
Floor4 lxmxn Posted 2006-10-29 13:47
版主 Posts 4,938 Credits 11,386


  Re: panhong1986

  The following is a reply to your topic, and it can also be regarded as a summary of the functions of characters in the learning process of batch processing by myself.

  The following summary is limited by my ability and experience, so there are inevitable mistakes or omissions. If there are any problems, you and everyone are welcome to criticize and correct. The following is not comprehensive, and it will be gradually supplemented later.

: The content after \\ is a comment; in addition, thanks to qzwqzw for supplementing this material.
__________________________________________________________________________________________

@
\\Hide the echo of the command.

~
\\In for, it means using enhanced variable expansion;
In set, it means using the string of the specified position of the extended environment variable;
In set/a, it means bitwise negation.

%
\\Using two % to contain a string means to reference an environment variable. For example, a %time% can be expanded to the current system time;
A single % followed by a number from 0-9 means to reference a command line parameter;
Used in for to mean referencing a loop variable;
Two consecutive % mean to be reduced to one % during execution.

^
\\Cancel the escape character, that is, turn off the escape function of all escape characters. For example, to display some special characters on the screen, such as > >> | ^, etc., you can add a ^ symbol in front of it to display the character after this ^, ^^ is to display a ^, ^| is to display a | character;
In set/a, it is bitwise XOR;
In the of findstr/r, it means not matching the specified character set.

&
\\Command connection character. For example, if I want to execute two commands on one line of text, I can use the & command to connect these two commands;
In set/a, it is bitwise AND.

*
\\Represents any number of any characters, which is the so-called "wildcard"; for example, if you want to find all text files (.txt) in the root directory of the C drive, you can enter the command "dir c:\*.txt";
In set/a, it is multiplication. For example, "set/a x=4*2", the result is 8;
In findstr/r, it means to match the previous character multiple times.

()
\\Command inclusion or a delimiter with priority. For example, the for command uses this (), and we can also see its presence in commands such as if and echo;

-
\\Range identifier, such as date lookup, can be used in the tokens operation in the for command;
In findstr/r, connect two characters to represent matching range;
- After some commands' / indicates taking the reverse switch.

+
\\Mainly used in the copy command, it means to combine many files into one file, and this + character is used;
In set/a, it is addition.

|
\\Pipe character. It means to use the output of the previous command as the input of the next command. "dir /a/b | more" can display the information output by the dir command screen by screen;
In set/a, it is bitwise OR;
In the help document, it means that the two switches, options or parameters before and after it are optional.

:
\\Label locator, which can accept the label pointed to by the goto command. For example, if a ":begin" label is defined in the batch file, the "goto begin" command can be used to go to the ":begin" change and execute the batch command later.

" "
\\Delimiter, when indicating a path with spaces, "" is often used to enclose the path, and "" symbols are also needed in some commands;
In for/f, it means that the content they contain is analyzed as a string;
In for/f "usebackq" means that the content they contain is regarded as a file path and the content of its file is analyzed;
In other cases, it means that the content inside is a complete string, and >, >>, <, &, |, space, etc. are no longer escaped.

/
\\Indicates that the character (string) after it is the function switch (option) of the command. For example, "dir /s/b/a-d" means different parameters specified by the "dir" command;
In set/a, it means division.

>
\\Command redirection character, redirect the output result of the previous command to the device behind it, and the content in the subsequent device is overwritten. For example, you can use "dir > lxmxn.txt" to output the result of the "dir" command to the text file "lxmxn.txt";
In findstr/r, it means matching the right boundary of the word, which needs to be used with the escape character \.

>>
\\Command redirection character. Redirect the output result of the previous command to the device behind it, and the content in the subsequent device is not overwritten.

<
\\Use the content of the file behind it as the input of the previous command.
In findstr/r, it means matching the left boundary of the word, which needs to be used with the escape character \.

=
\\Assignment symbol, used for variable assignment. For example, "set a=windows" means assigning the string "windows" to the variable "a";
In set/a, it means arithmetic operation, for example, "set /a x=5-6*5".

\
\\In some cases, this "\" symbol represents the root directory of the current path. For example, if the current directory is under c:\windows\system32, then "dir \"" is equivalent to "dir c:\"
In findstr/r, it means a regular escape character.

''
In for/f, it means that the content they contain is executed as a command line and analyzed;
In for/f "usebackq", it means that the string they contain is analyzed as a string.

.
\\
When followed immediately after \ in the path or appearing alone:
One. means the current directory;
Two. means the upper level directory;
When appearing in the file name in the path:
The last. means the separator between the main file name and the extension file name.

&&
\\Connect two commands, and the command after && will be executed only if the command before && is successful;

||
\\Connect two commands, and the command after || will be executed only if the command before || fails.

$
\\In the findstr command, it means the end of a line.

``
In for/f, it means that the content they contain is executed as a command line and its output is analyzed.


In the help document, it means that the switches, options or parameters inside are optional;
In findstr/r, it means matching according to the specified character set.

?
\\In findstr/r, it means matching an arbitrary character at this position;
? in the path means matching any one character at this position;
Immediately after / means to get the help document of the command.

!
\\When variable delay is enabled, use!! to enclose the variable name to mean referencing the variable value;
In set /a, it means logical NOT. For example, set /a a=!0, then a means logical 1.
__________________________________________________________________________________________

①: The fourth supplementary material was on 2006.10.30.
②: The fourth supplementary material was on 2006.11.08.
③: The fourth supplementary material was on 2006.01.24.
④: The fourth supplementary material was on 2007.03.13.


[ Last edited by lxmxn on 2007-4-5 at 01:37 PM ]
Floor5 panhong1986 Posted 2006-10-29 14:25
初级用户 Posts 10 Credits 29
WOW.... THANK U SO MUCH,DUDE
Floor6 panhong1986 Posted 2006-10-29 14:30
初级用户 Posts 10 Credits 29
It's rare to have such a detailed explanation. When you finish writing all of them, I'll copy them down.
Floor7 redtek Posted 2006-10-29 20:01
金牌会员 Posts 1,147 Credits 2,902
lxmxn wrote it really detailed! +10 points~ : )
Floor8 hxuan999 Posted 2006-11-23 06:40
中级用户 Posts 161 Credits 337
Hard work pays off. Hehe
Floor9 love200052 Posted 2006-11-26 09:13
初级用户 Posts 15 Credits 43
Well written! Thanks a lot, lxmxn!
Floor10 ynjzlzd Posted 2006-12-05 21:39
初级用户 Posts 12 Credits 28
Please trouble the expert upstairs to fill in when free, we are waiting patiently.
Floor11 23985940 Posted 2006-12-06 02:04
新手上路 Posts 2 Credits 4
Really learned something here. There are really many experts!
Floor12 lxmxn Posted 2006-12-08 14:10
版主 Posts 4,938 Credits 11,386
Originally posted by ynjzlzd at 2006-12-5 21:39:
Trouble the master upstairs to supplement when free, we are waiting patiently.


  Several symbols have been supplemented today, it seems there are no other symbols. =_=
Floor13 FJY206 Posted 2006-12-16 05:05
新手上路 Posts 6 Credits 12
Thanks
Floor14 nt101007 Posted 2006-12-17 04:31
初级用户 Posts 14 Credits 28
Can't see clearly?
Floor15 lxmxn Posted 2006-12-17 16:08
版主 Posts 4,938 Credits 11,386
Originally posted by nt101007 at 2006-12-17 04:31:
Can't see clearly? 》


  What is not clear? I was afraid the font was too small to see clearly, so I特意 adjusted the font to a relatively large size. Why is it still not clear?
1 2 3 49  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023