China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-22 22:25
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Reference for Arrangement] The Role of Symbols under CMD/DOS StickyI View 153,265 Replies 216
Floor 31 Posted 2007-06-27 01:51 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline
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.
Floor 32 Posted 2007-06-27 18:16 ·  中国 云南 昆明 教育网
新手上路
Credits 18
Posts 7
Joined 2007-06-12 22:13
19-year member
UID 91120
Gender Male
Status Offline
Good stuff, thanks to the楼主. I have downloaded it as a DOC document and printed it for study.
Floor 33 Posted 2007-08-04 08:24 ·  中国 黑龙江 鸡西 联通
初级用户
Credits 25
Posts 14
Joined 2006-11-02 01:05
19-year member
UID 69226
Gender Male
Status Offline
:lol:
This post is strong, worthy of the Party
Floor 34 Posted 2007-08-04 08:55 ·  中国 河北 廊坊 三河市 移动
金牌会员
★★★★
Credits 2,725
Posts 1,160
Joined 2006-09-23 12:00
19-year member
UID 63486
From 河北廊坊
Status Offline
This is indeed a very valuable article, which is quite helpful for understanding cmd.
三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。
Floor 35 Posted 2007-09-03 10:51 ·  中国 云南 西双版纳傣族自治州 电信
初级用户
★★
Credits 100
Posts 52
Joined 2006-03-02 15:06
20-year member
UID 51231
From 云南
Status Offline
ok
Floor 36 Posted 2007-09-07 10:29 ·  中国 北京 鹏博士BGP
初级用户
Credits 66
Posts 29
Joined 2007-09-06 15:09
18-year member
UID 96715
Gender Male
Status Offline
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.
Floor 37 Posted 2007-09-09 01:45 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline
Re flamemperor:

Did you start with Setlocal EnableDelayedExpansion?

Please post your code for us to see?
Floor 38 Posted 2007-09-14 13:56 ·  中国 北京 联通
初级用户
Credits 66
Posts 29
Joined 2007-09-06 15:09
18-year member
UID 96715
Gender Male
Status Offline
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.
Floor 39 Posted 2007-09-28 18:41 ·  中国 浙江 宁波 电信
初级用户
Credits 87
Posts 42
Joined 2007-09-27 19:25
18-year member
UID 98424
Gender Male
Status Offline
What else is there to say! Just top it first
Floor 40 Posted 2007-09-30 09:12 ·  中国 重庆 中移铁通
初级用户
Credits 70
Posts 33
Joined 2007-06-03 21:10
19-year member
UID 90174
Gender Male
Status Offline
Learned it
Floor 41 Posted 2007-10-03 14:14 ·  中国 广东 东莞 电信
初级用户
Credits 63
Posts 18
Joined 2006-09-09 08:41
19-year member
UID 62219
Status Offline
I've always read posts without replying in cn-dos. Seeing this great post, I think I need to change my bad habit.
Floor 42 Posted 2007-10-04 16:51 ·  中国 福建 泉州 电信
新手上路
Credits 4
Posts 2
Joined 2007-10-04 14:04
18-year member
UID 98876
Gender Male
Status Offline
Non-sense thanks to version master lxmxn
Benefited a lot!!!
Floor 43 Posted 2007-10-07 08:10 ·  中国 湖北 黄冈 电信
初级用户
★★
Credits 153
Posts 54
Joined 2007-06-20 18:24
19-year member
UID 91903
Gender Male
Status Offline
Just happened to not understand, it helped me a lot
Floor 44 Posted 2007-10-07 12:41 ·  中国 湖北 武汉 电信
初级用户
Credits 97
Posts 33
Joined 2007-03-05 06:13
19-year member
UID 80815
Gender Male
Status Offline
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 里面一定要加上^
```
Floor 45 Posted 2007-10-07 18:01 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline
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 ]
Forum Jump: