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 ]
Recent Ratings for This Post
( 10 in total)
Click for details