我正在尝试制作一个在文件中搜索两个不同字符串的批处理文件。然后从第一次搜索中取出第一行,从第二次搜索中取出第一行,并将它们合并为一行。
我意识到这超出了我的批量技能,因此将不胜感激。
提前致谢!
@echo off
for /f %%G in (file.txt) do (
findstr "word1" *.* > result.txt
findstr "word2" *.* >> result.txt)
例子:
文件.txt:
hello i'm a line with word1
hello i'm a line with word2
hello i'm another line with word1
hello i'm another line with word2
hello i'm yet another line with word1
hello i'm yet another line with word2
结果.txt:
hello i'm a line with word1hello i'm a line with word2
hello i'm another line with word1hello i'm another line with word2
hello i'm yet another line with word1hello i'm yet another line with word2