中国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-11-10 11:25
47,815 topics / 349,930 posts / today 0 new / 48,291 members
DOS批处理 & 脚本技术(批处理室) » [Reference for Arrangement] The Role of Symbols under CMD/DOS
Printable Version  162,502 / 216
Floor31 lxmxn Posted 2007-06-27 01:51
版主 Posts 4,938 Credits 11,386
RE qzwqzw:

It has been corrected. However, this "character acts to cancel the special uses for other special symbols (such as ^, &, |). So it feels safer to add a pair of "" when using the set /a command. Hehe.
Floor32 vivi Posted 2007-06-27 18:16
新手上路 Posts 7 Credits 18
Good stuff, thanks to the楼主. I have downloaded it as a DOC document and printed it for study.
Floor33 windowsxphao Posted 2007-08-04 08:24
初级用户 Posts 14 Credits 25
:lol:
This post is strong, worthy of the Party
Floor34 ccwan Posted 2007-08-04 08:55
金牌会员 Posts 1,160 Credits 2,725 From 河北廊坊
This is indeed a very valuable article, which is quite helpful for understanding cmd.
Floor35 long626201 Posted 2007-09-03 10:51
初级用户 Posts 52 Credits 100 From 云南
ok
Floor36 flamemperor Posted 2007-09-07 10:29
初级用户 Posts 29 Credits 66
Ask about this:

! !
① When variable delay is enabled, enclosing the variable name with !! means referring to the variable value.
I enabled variable delay and used !! to reference the variable, but it didn't work.
Is there any other condition needed?

I'm relatively stupid, please forgive me.
Floor37 lxmxn Posted 2007-09-09 01:45
版主 Posts 4,938 Credits 11,386
Re flamemperor:

Did you start with Setlocal EnableDelayedExpansion?

Please post your code for us to see?
Floor38 flamemperor Posted 2007-09-14 13:56
初级用户 Posts 29 Credits 66
Thanks to the moderator for replying. I've already solved the problem. It was my own mistake. Thank you. Now I'm still a bit confused about variable delays, and I'll keep learning.
Floor39 wordexport Posted 2007-09-28 18:41
初级用户 Posts 42 Credits 87
What else is there to say! Just top it first
Floor40 binggao Posted 2007-09-30 09:12
初级用户 Posts 33 Credits 70
Learned it
Floor41 002500 Posted 2007-10-03 14:14
初级用户 Posts 18 Credits 63
I've always read posts without replying in cn-dos. Seeing this great post, I think I need to change my bad habit.
Floor42 reubon Posted 2007-10-04 16:51
新手上路 Posts 2 Credits 4
Non-sense thanks to version master lxmxn
Benefited a lot!!!
Floor43 zwdeee Posted 2007-10-07 08:10
初级用户 Posts 54 Credits 153
Just happened to not understand, it helped me a lot
Floor44 qdloverr Posted 2007-10-07 12:41
初级用户 Posts 33 Credits 97
The `^` is an escape character. In a batch file, the `|` is a special character that has a specific meaning (pipeline operation). When using `|` inside a `for /f` command, it needs to be escaped with `^` so that the shell interprets it correctly as part of the command being passed to `find /i "Physical Address"` rather than as a special operator within the batch file's syntax itself.

So the translated text remains as the original batch code part:
```
for /f "tokens=2 delims=:" %%a in ('ipconfig /all^|find /i "Physical Address"') do echo %%a>c:\MAC.txt
问题来了,'ipconfig /all^|find /i "Physical Address"'
既然是让 'ipconfig /all传输给下一个命令 为什么又用^这个符号来取消|的作用呢?
如果只运行'ipconfig /all^|find /i "Physical Address
可以不需要这个符号
为什么在for 里面一定要加上^
```
Floor45 lxmxn Posted 2007-10-07 18:01
版主 Posts 4,938 Credits 11,386
RE qdloverr:

for /f "tokens=2 delims=:" %%a in ('ipconfig /all^|find /i "Physical Address"') do echo %%a>c:\MAC.txt

If you don't add ^ before | between ipconfig /all and find, this statement can be understood as:
for /f "tokens=2 delims=:" %%a in ('ipconfig /all is passed to find /i "Physical Address"') do echo %%a>c:\MAC.txt, which obviously leads to a syntax error. This may be caused because the priority of the pipe symbol (|) is higher than the parentheses () after in in the for command.

If you don't add ^, to make ipconfig /all|find /i "Physical Address" a whole, maybe it can be like this:
for /f "tokens=2 delims=:" %%a in (' "ipconfig /all|find /i "Physical Address" "') do echo %%a>c:\MAC.txt


[ Last edited by lxmxn on 2007-10-7 at 06:03 PM ]
Prev  1 2 3 4 5 6 … 15  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023