我有一个名为file.txt的文本文件,其中包含
A: - No such Root Directory
B: - No such Root Directory
C: - Fixed Drive
D: - Fixed Drive
E: - Removable Drive
F: - CD-ROM Drive
G: - Removable Drive
H: - No such Root Directory
I: - No such Root Directory
J: - No such Root Directory
K: - No such Root Directory
M: - No such Root Directory
N: - No such Root Directory
O: - No such Root Directory
P: - No such Root Directory
Q: - No such Root Directory
R: - No such Root Directory
S: - No such Root Directory
T: - No such Root Directory
U: - No such Root Directory
V: - No such Root Directory
W: - No such Root Directory
X: - No such Root Directory
Y: - No such Root Directory
Z: - No such Root Directory在这个文件中,您可以注意到第5行和第7行中出现了两个单词Removable。
如果它有相同的特定单词Removable两次或三次,它需要显示输出有Removable word found multiple times。
如果它没有相同的特定单词Removable两次或三次,它需要显示输出有There is no multiple Removable word found。
对于这个输出,我运行了以下程序,
findstr /b Removable "file.txt" do (
echo Removable word found multiple times
) || (
echo There is no multiple Removable word found
)
pause我知道这是错误的。但是我已经尽力了。朋友们,请纠正我。这对我会很有帮助的。
发布于 2017-08-26 17:47:00
您应该能够使用Find /I /C "Removable"<"file.txt"来获取该文件中可移动实例的数量。你要做的就是检查那个号码。最常见的方法是通过将该命令放在for循环中读取该值。
就像命令提示符窗口中的这一行:
For /F %A In ('Find /I /C "Removable"^<"file.txt"') Do @If %A Lss 1 (Echo=There is no multiple Removable word found) Else Echo Removable word found %A timeshttps://stackoverflow.com/questions/45898005
复制相似问题