中国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-08-09 02:23
47,811 topics / 349,895 posts / today 0 new / 48,253 members
DOS批处理 & 脚本技术(批处理室) » Please explain this batch file of yours, zw19750516
Printable Version  671 / 1
Floor1 hackerscans Posted 2008-06-20 18:10
初级用户 Posts 51 Credits 73
@echo off
for /f "tokens=3,5,7,8 delims==/> " %%i in ('findstr "FACTORY DUT" 1.txt^|findstr /v "FIXTURE"') do call :lp %%i %%j %%k %%l
pause>nul&goto :eof
:lp
set str=%1
if defined str echo %str:~1,-1%
if defined str shift&goto lp

Thanks, and experts are also welcome to chime in.
Floor2 bat-zw Posted 2008-06-20 18:31
金牌会员 Posts 1,276 Credits 3,105
Sheesh, why does everyone want an explanation.
What comes before :lp is using suitable delimiters and a for+findstr statement to grab the wanted strings from 1.txt, so I won't explain that in detail.
I believe newbies may have a bit of trouble understanding the shift statement after the :lp label. Actually, if you just type shift /? in cmd, you can get a basic idea that what shift does is shift the parameters after call. And here shift is doing the same thing: first, four parameters are passed over from the for statement, namely %%i %%j %%k %%l, that is, %1 %2 %3 %4. Each time lp loops once, shift moves the parameters one place back. The first time, the parameter is %1=%%i, but the second time %1 moves to the second position, so now %1=%%j, and this continues until %1 has been shifted to the position of the last parameter.

[ Last edited by zw19750516 on 2008-6-20 at 06:34 PM ]
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023