我们需要一个适用于 Windows 的脚本来复制以特定单词开头的整行并粘贴到另一个 txt 文件
源文件:
< Date: Wed, 18 Jan 2023 00:12:13 GMT
< Content-Length: 0
Compare hash: 74d05d5b127a8cd4b4781f1956b78df7771112436c89b2c9
< Connection: keep-alive
< Date: Wed, 18 Jan 2023 00:12:19 GMT
< Content-Length: 0
Compare hash: 52d05d5b127a8cd4b4781f1956b78df4401112436c89b258
< Connection: keep-alive
< Date: Wed, 18 Jan 2023 00:12:20 GMT
< Content-Length: 0
Compare hash: 33d05d5b127a8cd4b4781f1956b78df7661112436c89b277
< Connection: keep-alive
我们只需要提取每行的第三行并将其粘贴到另一个文本文件中,结果将是这样的:
Compare hash: 74d05d5b127a8cd4b4781f1956b78df7771112436c89b2c9
Compare hash: 52d05d5b127a8cd4b4781f1956b78df4401112436c89b258
Compare hash: 33d05d5b127a8cd4b4781f1956b78df7661112436c89b277
答案1
如果所有不应复制的行都包含小于“<”符号,那么也许这样做可以解决问题:
type "Original.txt" |find /v "<">>"New.txt"
或者如果您想要所有包含“比较哈希”的行:
type "Original.txt" |find /i "Compare hash">>"New.txt"