中国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-10-24 03:19
47,815 topics / 349,928 posts / today 1 new / 48,287 members
DOS批处理 & 脚本技术(批处理室) » Question: how to search for a specific string in a txt file
Printable Version  5,894 / 20
Floor16 zreo Posted 2005-11-14 23:57
初级用户 Posts 14 Credits 51
if "%a%" NEQ " ...

I'd like to ask, why does it have to be %a%, and why won't just one % work here? Also, what does NEQ mean?
Floor17 无奈何 Posted 2005-11-15 00:31
荣誉版主 Posts 356 Credits 1,338
Originally posted by malongxa at 2005-11-14 22:10:
Could the moderator and 无奈何, you two experts, explain in detail how to use "delims= token=2"? I still have no way to capture specific characters. Thanks again to both of you experts!!


delims= means splitting the text using as delimiters, and token=2 means starting from the second field.
See for /? for details


I'd like to ask, why does it have to be %a%, and why won't just one % work here? Also, what does NEQ mean?


%a% is an environment variable, not a loop variable.
For NEQ, see: if /?
Floor18 willsort Posted 2005-11-15 09:12
元老会员 Posts 1,512 Credits 4,432
Re malongxa:

Under NT CMD there are two ways to “capture” specific characters (strings): one is to use for /f to analyze the characteristics of the boundaries before and after the string, which is suitable for extracting words or strings located between spaces or certain special characters; the other is to use set to analyze the row and column position of the string, which is suitable for extracting strings at known positions.

As for extracting “nate” as you said, you haven't considered by what method to extract it—whether it is the string in columns 28-32, or the string after Alter and before the space. This determines the difference in implementation.

[ Last edited by willsort on 2005-11-17 at 18:04 ]
Floor19 malongxa Posted 2005-11-16 10:41
初级用户 Posts 11 Credits 26
Thanks for the moderator's guidance. I want to learn both methods. Could you give me the solutions? Thanks again for the moderator's guidance.
Floor20 Climbing Posted 2005-11-17 03:45
铂金会员 Posts 2,753 Credits 6,964 From 河北保定
Don't keep asking people to guide you, it has already been explained in great detail. Look at the results of these three commands, read them carefully, and try them slowly:
for /?
if /?
set /?

Only what you figure out yourself truly belongs to you. If the same command has been repeated to you N times and you still don't understand it, the reason is exactly that it was told to you by someone else.
Floor21 malongxa Posted 2005-11-17 09:23
初级用户 Posts 11 Credits 26
to:Climbing
Hello! As for these three commands, the purpose of my first post has already been achieved. Because I want to infer more from one example and study these three commands more deeply, I also tested many times by myself. It is precisely because there are some uses in /? that I don't understand that I asked the moderator to give his method as an example so I can learn. Please don't think I am someone who doesn't work hard. Thanks again to the moderator and 无奈何!
Prev  1 2
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023