|
ghtfuo
初级用户
 
积分 122
发帖 12
注册 2004-4-24
状态 离线
|
『第 16 楼』:
使用 LLM 解释/回答一下
命令提示符
批处理中
记住了,谢谢你
Command Prompt
In batch processing
Remembered, thank you
|
|
2006-10-26 05:05 |
|
|
ghtfuo
初级用户
 
积分 122
发帖 12
注册 2004-4-24
状态 离线
|
『第 17 楼』:
使用 LLM 解释/回答一下
for/?
后面有几种用法
For the `for` command in DOS, there are several common usages:
1. `for %variable in (set) do command ` - Iterates over a set of files or values. For example, `for %i in (*.txt) do type %i` to display the contents of all text files.
2. `for /f %variable in (file-set) do command ` - Reads the contents of a file and performs commands on each line. For example, `for /f "delims=" %i in (test.txt) do echo %i` to echo each line in the test.txt file.
3. `for /l %variable in (start, step, end) do command ` - Performs a loop from the start number to the end number with a specified step. For example, `for /l %i in (1,1,5) do echo %i` to echo numbers 1 to 5.
4. `for /r path] %variable in (file-set) do command ` - Recursively searches for files in a directory tree. For example, `for /r c:\ %i in (*.exe) do echo %i` to echo all executable files in the C drive and its subdirectories.
|
|
2006-10-26 05:08 |
|
|
ghtfuo
初级用户
 
积分 122
发帖 12
注册 2004-4-24
状态 离线
|
『第 18 楼』:
使用 LLM 解释/回答一下
格式就是
for/? %? +方式 +(范围)+动作+起始对象 +%?
是不是这样啊
The format is
for/? %? + method + (range) + action + starting object + %?
Is it like this?
|
|
2006-10-26 05:13 |
|
|
ghtfuo
初级用户
 
积分 122
发帖 12
注册 2004-4-24
状态 离线
|
『第 19 楼』:
使用 LLM 解释/回答一下
意思就是把所求的结果作为一个变量%X以什么样的方式用什么样的范围对一个对象做什么动作
然后把结果显出来?
It means what kind of way and within what range to perform an action on an object by taking the desired result as a variable %X, and then display the result?
|
|
2006-10-26 05:19 |
|
|
lxmxn
版主
       
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
『第 20 楼』:
使用 LLM 解释/回答一下
恩,大致是这样的吧。只要你自己真正理解了它的原理就够了。还是建议要多多练习for语句的使用,练习多了自然就对它更了解,用它解决问题就更得心应手了。
Well, it's roughly like this. As long as you truly understand its principle by yourself. It is still recommended to practice the use of the for statement more. After practicing more, you will naturally have a better understanding of it and be more proficient in using it to solve problems.
|
|
2006-10-26 12:15 |
|
|
ghtfuo
初级用户
 
积分 122
发帖 12
注册 2004-4-24
状态 离线
|
『第 21 楼』:
使用 LLM 解释/回答一下
好的
谢谢了
我看看cmd中的帮助
Okay, thank you. I'll take a look at the help in cmd.
|
|
2006-10-27 08:04 |
|
|
ghtfuo
初级用户
 
积分 122
发帖 12
注册 2004-4-24
状态 离线
|
『第 22 楼』:
使用 LLM 解释/回答一下
FOR /F ["options"] %variable IN (file-set) DO command [command-parameters]
FOR /F ["options"] %variable IN ("string") DO command [command-parameters]
FOR /F ["options"] %variable IN ('command') DO command [command-parameters]
file-set
"string"
'command'
各指代的是什么动作
“options”里面是不是可以载入这些
eol=c
skip=n
delims=xxx
tokens=x,y,m-n
usebackq
FOR /F %variable IN (file-set) DO command
FOR /F %variable IN ("string") DO command
FOR /F %variable IN ('command') DO command
file-set refers to specifying a file or files.
"string" refers to specifying a string directly.
'command' refers to executing a command and using its output.
Can "options" load these
eol=c
skip=n
delims=xxx
tokens=x,y,m-n
usebackq
|
|
2006-10-27 08:14 |
|
|
lxmxn
版主
       
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
『第 23 楼』:
使用 LLM 解释/回答一下
Re : ghtfuo
file-set:代表for执行的对象是一个文件,也可以是多个文件,同时支持通配符"?"和"*";
"string":表示for执行的对象是一个字符串,比如"www.Cn-Dos.Net"这个字符串;
for /f "tokens=1,* delims=-" %i in ("www.Cn-Dos.Net") do @echo %i+%j执行的结果是:"www.Cn+Dos.Net";
'command':表示for执行的对象是一个命令的输出,比如"ipconfig /all"这个命令;
for /f "delims=: tokens=1*" %i in ('ipconfig /all^|find /i "ip address"') do @echo %j执行的结果是你的ip地址.
至于"Options",你说的是对的.
要多多体会这个命令的用法才能真正掌握它.
Last edited by lxmxn on 2006-10-30 at 06:24 AM ]
Re: ghtfuo
file-set: represents that the object for which for is executed is a file, or multiple files, and supports wildcards "?" and "*" at the same time;
"string": indicates that the object for which for is executed is a string, such as the string "www.Cn-Dos.Net";
The result of executing for /f "tokens=1,* delims=-" %i in ("www.Cn-Dos.Net") do @echo %i+%j is: "www.Cn+Dos.Net";
'command': indicates that the object for which for is executed is the output of a command, such as the command "ipconfig /all";
The result of executing for /f "delims=: tokens=1*" %i in ('ipconfig /all^|find /i "ip address"') do @echo %j is your IP address.
As for "Options", you are right.
You need to experience the usage of this command more to truly master it.
Last edited by lxmxn on 2006-10-30 at 06:24 AM ]
|
|
2006-10-27 21:46 |
|
|
ghtfuo
初级用户
 
积分 122
发帖 12
注册 2004-4-24
状态 离线
|
『第 24 楼』:
使用 LLM 解释/回答一下
delims的意思就是把执行语句中的每一次循环的处理结果,分割组合成一个集
tokens则是取一次往前移动一定步幅所得到的字符?
('ipconfig /add^|find /i "ip address"')这个括号里add^|find /i "的含义我不了解
Last edited by ghtfuo on 2006-10-30 at 06:21 AM ]
The meaning of delims is to split and combine the processing results of each loop in the execution statement into a set. Tokens is to take a character obtained by moving a certain step forward at a time? The meaning of "add^|find /i "" in the parentheses of ('ipconfig /add^|find /i "ip address"') I don't understand.
Last edited by ghtfuo on 2006-10-30 at 06:21 AM ]
|
|
2006-10-30 06:19 |
|
|
lxmxn
版主
       
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
『第 25 楼』:
使用 LLM 解释/回答一下
Re : ghtfuo
哦,不要意思啊,打错了,我已经改了,这里的"add"应该是"all",这个"/all"是"ipconfig"命令的参数,它的作用就是显示计算机当前的TCP/IP配置的详细信息,包括IP,MAC,网关,和主机名等相关信息.是相对"ipconfig"命令没有参数的情况的..
这里的"('ipconfig /all^|find /i "ip address"')"应该看作两个部分来理解,一个是"ipconfig /all",而另一个是"find /i "ip address"",前者在上面已经讲过了,而后者中的"/i"是"find"命令的参数,表示查找时忽略大小写,举个例子吧来看吧.
比如现在有一个文件abc.txt,里面的内容是:
--------------------abc.txt---------------------------------------------
www.Cn-DoS.net
www.cn-dos.net
--------------------abc.txt---------------------------------------------
只有这两行内容,那么在命令提示符里面执行"find "Cn-DoS" abc.txt",就可以找到第一行的内容,如果你用"find "cn-dos" abc.txt",就可以找到第二行的内容,如果你用到了"/i"这个参数,那么就表示查找字符串的时候忽略大小写,所以如果执行"find /i "cn-Dos" abc.txt"的话,那么abc.txt中的两行内容都可以找到..
这里的"^|"是管道符,作用是把"ipconfig /all"的结果传输到"find /i "ip address""命令,也可以理解为把"ipconfig /all"的结果作为"find /i "ip address""命令的对象.而这里的"^"符号,是转义字符,之所以加上这个"^",是由于for命令的特性决定的.在for命令的括号里面使用管道符号"|",必须在前面加上一个"^"作为转义.
另外,建议你多看看系统自带的帮助文档.或者直接在命令行"命令 /?"查看帮助.
hh ntcmds.chm::ntcmds.htm
Last edited by lxmxn on 2006-10-30 at 07:30 AM ]
Re: ghtfuo
Oh, sorry, I made a mistake. I've corrected it. Here, "add" should be "all". This "/all" is a parameter of the "ipconfig" command. Its function is to display the detailed information of the current TCP/IP configuration of the computer, including IP, MAC, gateway, and host name, etc. This is in contrast to the situation where the "ipconfig" command has no parameters..
Here, "('ipconfig /all^|find /i "ip address"')" should be understood in two parts. One is "ipconfig /all", and the other is "find /i "ip address"". The former has been explained above, and the "/i" in the latter is a parameter of the "find" command, which means ignoring case when searching. Let's take an example.
For example, there is a file abc.txt with the following content:
--------------------abc.txt---------------------------------------------
www.Cn-DoS.net
www.cn-dos.net
--------------------abc.txt---------------------------------------------
There are only these two lines. Then, executing "find "Cn-DoS" abc.txt" in the command prompt can find the content of the first line. If you use "find "cn-dos" abc.txt", you can find the content of the second line. If you use the "/i" parameter, it means ignoring case when searching. So, if you execute "find /i "cn-Dos" abc.txt", then both lines in abc.txt can be found..
Here, "^|" is the pipe symbol, which functions to transfer the result of "ipconfig /all" to the "find /i "ip address"" command. It can also be understood as taking the result of "ipconfig /all" as the object of the "find /i "ip address"" command. And the "^" symbol here is an escape character. The reason for adding this "^" is determined by the characteristics of the for command. When using the pipe symbol "|" inside the parentheses of the for command, a "^" must be added in front as an escape.
In addition, it is recommended that you read more of the system's built-in help documents. Or directly view the help with "command /?" in the command line.
hh ntcmds.chm::ntcmds.htm
Last edited by lxmxn on 2006-10-30 at 07:30 AM ]
|
|
2006-10-30 07:04 |
|
|
ghtfuo
初级用户
 
积分 122
发帖 12
注册 2004-4-24
状态 离线
|
『第 26 楼』:
使用 LLM 解释/回答一下
一说就明白了
就是这个帮助文件找不到了
才问的
As soon as you mention it, you'll understand. It's just that this help file can't be found, which is why I'm asking.
|
|
2006-10-30 07:15 |
|