    『第 4 楼』:
使用 LLM 解释/回答一下
Re : panhong1986
下面是对你的主题的回复,同时也算是自己对批处理学习过程中遇到的字符的作用的总结吧.
下面的总结,因本人能力和经验所限,因此难免会有写错的或者遗漏的地方,如果有问题,欢迎你以及大伙批评指正.下面的写的并不全面,以后再慢慢的补充上来.
[注]:\\后面的内容为注释;另外,感谢 qzwqzw 对此资料的补充。
__________________________________________________________________________________________
@
\\隐藏命令的回显。
~
\\在for中表示使用增强的变量扩展;
在set中表示使用扩展环境变量指定位置的字符串;
在set/a中表示按位取反。
%
\\使用两个%包含一个字符串表示引用环境变量。比如一个%time%可以扩展到当前的系统时间;
单个%紧跟0-9的一个数字表示引用命令行参数;
用于for中表示引用循环变量;
连续的两个%表示执行时脱为一个%。
^
\\取消转义字符,即将所有转义字符的转义作用关闭。比如要在屏幕显示一些特殊的字符,比如> >> | ^等时,就可以在其前面加一个^符号来显示这个^后面的字符了,^^就是显示一个^,^|就是显示一个|字符了;
在set/a中是按位异;
在findstr/r的中表示不匹配指定的字符集。
&
\\命令连接字符。比如我要在一行文本上同时执行两个命令,就可以用&命令连接这两个命令;
在set/a中是按位与。
*
\\代表任意个任意字符,就是我们通常所说的"通配符";比如想在c盘的根目录查找c盘根目录里所有的文本文件(.txt),那么就可以输入命令"dir c:\*.txt";
在set/a中是乘法。比如"set/a x=4*2",得到的结果是8;
在findstr/r中表示将前一个字符多次匹配。
()
\\命令包含或者是具有优先权的界定符吧,比如for命令要用到这个(),我们还可以在if,echo等命令中见到它的身影;
-
\\范围表示符,比如日期的查找,for命令里的tokens操作中就可以用到这个字符;
在findstr/r中连接两个字符表示匹配范围;
-跟在某些命令的/后表示取反向的开关。
+
\\主要是在copy命令里面会用到它,表示将很多个文件合并为一个文件,就要用到这个+字符了;
在set/a中是加法。
|
\\管道符。就是将上一个命令的输出,作为下一个命令的输入."dir /a/b | more"就可以逐屏的显示dir命令所输出的信息;
在set/a中是按位或;
在帮助文档中表示其前后两个开关、选项或参数是二选一的。
:
\\标签定位符,可以接受goto命令所指向的标签。比如在批处理文件里面定义了一个":begin"标签,用"goto begin"命令就可以转到":begin"变迁后面来执行批处理命令了。
" "
\\界定符,在表示带有空格的路径时常要用""来将路径括起来,在一些命令里面也需要" "符号;
在for/f中将表示它们包含的内容当作字符串分析;
在for/f "usebackq"表示它们包含的内容当作文件路径并分析其文件的内容;
在其它情况下表示其中的内容是一个完整的字符串,其中的>、>>、<、&、|、空格等不再转义。
/
\\表示其后的字符(串)是命令的功能开关(选项)。比如"dir /s/b/a-d"表示"dir"命令指定的不同的参数;
在set/a中表示除法。
>
\\命令重定向符,将其前面的命令的输出结果重新定向到其后面的设备中去,后面的设备中的内容被覆盖。比如可以用"dir > lxmxn.txt"将"dir"命令的结果输出到"lxmxn.txt"这个文本文件中去;
在findstr/r中表示匹配单词的右边界,需要配合转义字符\使用。
>>
\\命令重定向符。将其前面的命令的输出结果重新定向到其后面的设备中去,后面设备中的内容没有被覆盖。
<
\\将其后面的文件的内容作为其前面命令的输入。
在findstr/r中表示匹配单词的左边界,需要配合转义字符\使用。
=
\\赋值符号,用于变量的赋值。比如"set a=windows"的意思意思是将"windows"这个字符串赋给变量"a";
在set/a中表示算术运算,比如"set /a x=5-6*5"。
\
\\这个"\"符号在有的情况下,代表的是当前路径的根目录.比如当前目录在c:\windows\system32下,那么你"dir \"的话,就相当与"dir c:\"
在findstr/r中表示正则转义字符。
''
在for/f中表示将它们包含的内容当作命令行执行并分析其输出;
在for/f "usebackq"中表示将它们包含的字符串当作字符串分析。
.
\\
在路径的\后紧跟或者单独出现时:
一个.表示当前目录;
两个.表示上一级目录;
在路径中的文件名中出现时:
最后的一个.表示主文件名与扩展文件名的分隔。
&&
\\连接两个命令,当&&前的命令成功时,才执行&&后的命令;
||
\\连接两个命令,当||前的命令失败时,才执行||后的命令。
$
\\在findstr命令里面表示一行的结束。
``
在for/f中表示它们所包含的内容当作命令行执行并分析它的输出。
在帮助文档表示其中的开关、选项或参数是可选的;
在findstr/r中表示按其中指定的字符集匹配。
?
\\在findstr/r中表示在此位置匹配一个任意字符;
?在路径中表示在此位置通配任意一个字符;
紧跟在/后表示获取命令的帮助文档。
!
\\当启用变量延迟时,使用!!将变量名扩起来表示对变量值的引用;
在set /a中表示逻辑非。比如set /a a=!0,这时a就表示逻辑1。
__________________________________________________________________________________________
①:第四次补充资料于2006.10.30.
②:第四次补充资料于2006.11.08.
③:第四次补充资料于2006.01.24.
④:第四次补充资料于2007.03.13.
Last edited by lxmxn on 2007-4-5 at 01:37 PM ]
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 ]
此帖被 +50 点积分 点击查看详情 评分人:【 redtek 】 | 分数: +10 | 时间:2006-10-29 20:00 | 评分人:【 chainliq 】 | 分数: +6 | 时间:2007-1-13 04:37 | 评分人:【 sleet1986 】 | 分数: +1 | 时间:2007-1-13 07:15 | 评分人:【 zhxy9804 】 | 分数: +2 | 时间:2007-1-19 21:51 | 评分人:【 beeny 】 | 分数: +1 | 时间:2007-1-23 23:22 | 评分人:【 bob1989 】 | 分数: +1 | 时间:2007-1-25 00:23 | 评分人:【 electronixtar 】 | 分数: +23 | 时间:2007-3-16 10:41 | 评分人:【 dthao 】 | 分数: +4 | 时间:2007-11-4 07:06 | 评分人:【 lzl0532 】 | 分数: +1 | 时间:2008-1-11 17:15 | 评分人:【 mwm5 】 | 分数: +1 | 时间:2009-10-17 20:42 |
|
|