![]() |
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-06 05:02 |
48,039 topics / 350,124 posts / today 2 new / 48,251 members |
| DOS批处理 & 脚本技术(批处理室) » How to check at once whether any of multiple strings exists in a file |
| Printable Version 779 / 9 |
| Floor1 zerocq | Posted 2007-10-16 22:15 |
| 中级用户 Posts 196 Credits 458 | |
|
There are N strings used as signatures
A file may contain these N strings. How can I determine whether the file contains "any one" of these strings? Running "find string file" one by one is too slow. If there are too many signatures, the speed is very slow sed -e '/AAA/b' -e '/BBB/b' -e '/CCC/b' -e d test.txt&& echo %time% This command can search multiple strings at once, but from the returned result I can't tell whether it contains the strings Even if the file does not contain these strings it still shows %time% the same way, so how should this be written? Are there any other tools that can do this? :) |
|
| Floor2 lxmxn | Posted 2007-10-16 23:26 |
| 版主 Posts 4,938 Credits 11,386 | |
|
Put the strings to search below
sed.ini:
|
|
| Floor3 26933062 | Posted 2007-10-16 23:55 |
| 银牌会员 Posts 879 Credits 2,268 | |
| Floor4 zerocq | Posted 2007-10-17 00:27 |
| 中级用户 Posts 196 Credits 458 | |
Originally posted by lxmxn at 2007-10-16 23:26: Only one line in sed.ini works Multiple lines don't work?? |
|
| Floor5 zerocq | Posted 2007-10-17 00:33 |
| 中级用户 Posts 196 Credits 458 | |
Originally posted by 26933062 at 2007-10-16 23:55: |
|
| Floor6 26933062 | Posted 2007-10-17 01:16 |
| 银牌会员 Posts 879 Credits 2,268 | |
|
Looks like I can only run sed 3 times. Not sure about the efficiency
Each time replacing one string. |
|
| Floor7 lxmxn | Posted 2007-10-17 01:35 |
| 版主 Posts 4,938 Credits 11,386 | |
Originally posted by zerocq at 2007-10-17 00:27: I tested it, and multiple lines do work. G:\>type sed.ini [ Last edited by lxmxn on 2007-10-17 at 01:48 AM ] |
|
| Floor8 zerocq | Posted 2007-10-19 00:08 |
| 中级用户 Posts 196 Credits 458 | |
|
What operating system is the moderator using??
|
|
| Floor9 zerocq | Posted 2007-10-19 01:25 |
| 中级用户 Posts 196 Credits 458 | |
|
The problem has been solved, this thread can be closed
egrep.exe can support searching multiple strings at the same time, using | to separate the strings And it returns %errorlevel% correctly |
|
| Floor10 lxmxn | Posted 2007-10-19 17:14 |
| 版主 Posts 4,938 Credits 11,386 | |
|
My OS is Windows XP.
|
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |