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-08-09 09:13
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Help] Question about splitting with "delims=="? View 1,091 Replies 7
Original Poster Posted 2008-07-30 11:22 ·  中国 上海 上海地面通信息网络有限公司
中级用户
★★
Credits 240
Posts 115
Joined 2008-03-10 19:31
18-year member
UID 112561
Gender Male
Status Offline
set /f "delims==" %a in ('set') do echo %a will display the content before the = sign.
But if I want to get the characters after the = sign, then what? Experts, please teach me.
Floor 2 Posted 2008-07-30 12:20 ·  美国 惠普HP
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
Floor 3 Posted 2008-07-30 13:27 ·  中国 上海 上海地面通信息网络有限公司
中级用户
★★
Credits 240
Posts 115
Joined 2008-03-10 19:31
18-year member
UID 112561
Gender Male
Status Offline
Originally posted by HAT at 2008-7-30 12:20:
for /f "delims==" %a in ('set') do echo %b

I tried it, but it doesn't work. It just displays %b.
Floor 4 Posted 2008-07-30 13:29 ·  中国 北京 光环新网
银牌会员
★★★★
[b]看你妹啊[/b]
Credits 1,488
Posts 1,357
Joined 2006-05-20 12:00
20-year member
UID 55770
Status Offline
You probably need to add tokens.

有问题请发论坛或者自行搜索,再短消息问我的统统是SB
Floor 5 Posted 2008-07-30 13:34 ·  美国 惠普HP
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
Floor 6 Posted 2008-07-30 13:47 ·  中国 上海 上海地面通信息网络有限公司
中级用户
★★
Credits 240
Posts 115
Joined 2008-03-10 19:31
18-year member
UID 112561
Gender Male
Status Offline
Originally posted by HAT at 2008-7-30 13:34:
for /f "tokens=1,2 delims==" %a in ('set') do echo %b

It works now, thanks HAT.
Can you help explain it to me? Why does adding tokens=1,2 make it take the right side instead? But adding tokens=1 doesn't work.
Thanks.
Floor 7 Posted 2008-07-30 14:51 ·  美国 惠普HP
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
tokens=1 means only taking the first column; at that point only %a is valid.
Floor 8 Posted 2008-07-31 18:40 ·  中国 北京 光环新网
银牌会员
★★★★
[b]看你妹啊[/b]
Credits 1,488
Posts 1,357
Joined 2006-05-20 12:00
20-year member
UID 55770
Status Offline
Actually... after for /?

there is a line like this, FOR /F "usebackq delims==" %i IN (`set`) DO @echo %i
I only just noticed it myself

有问题请发论坛或者自行搜索,再短消息问我的统统是SB
Forum Jump: