我正在嘗試製作一個批處理文件,用於在文件中搜索兩個不同的字符串。然後從第一個搜索中取第一行,從第二個搜索中取第一行,並將它們組合成一行。搜索兩個字符串,然後將結果加在一起
我意識到這是對我的技能批量的方式,所以一點幫助,將不勝感激。
在此先感謝!
@echo off
for /f %%G in (file.txt) do (
findstr "word1" *.* > result.txt
findstr "word2" *.* >> result.txt)
實施例:
file.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
的Result.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
向我們展示您到目前爲止的內容。 SO不是「爲我免費編寫代碼」類型的網站。 –
如此編輯我目前的工作 – user2553264
這兩個單詞是固定的,還是來自'file.txt'? –