楼 主
find命令在查找文件中特定字符串中的应用
发表于 2006-06-28 14:38 · 中国 北京 联通
初级用户
★
积分 120
发帖 32
注册 2006-06-19 16:31
20年会员
UID 57256
状态 离线
@echo off
find "worldcup" e:\files\test.txt
if ERRORLEVEL 1 echo String "worldcup" has already existed in file "e:\files\test.txt"
pause
test.txt内容为:
worldcup
Euro Championship
Aisa Championship
在test.txt中存在的worldcup,为什么用上诉批处理,不能输出 存在提示呢?
第 2 楼
发表于 2006-06-28 18:32 · 中国 四川 南充 电信
超级版主
★★★★
我爱DOS
积分 5,310
发帖 2,044
注册 2005-09-26 12:00
20年会员
UID 42843
性别 男
来自 四川南充
状态 离线
@echo off
find "worldcup" e:\files\test.txt>nul
if ERRORLEVEL 0 echo String "worldcup" has already existed in file "e:\files\test.txt"
pause
第 3 楼
发表于 2006-07-01 09:24 · 中国 四川 成都 鹏博士宽带
荣誉版主
★★★★
batch fan
积分 5,226
发帖 1,737
注册 2006-03-10 00:38
20年会员
UID 51697
来自 成都
状态 离线
楼主对错误码的理解有问题,如果错误码为1,一般是表示执行失败。
论坛跳转: