我有两个文本文件mount.txt
,mount2.txt
并且我一直在尝试将新行(不在 mount.txt 中但在 mount2.txt 中的行)与旧行(在 mount.txt 中但不在 mount2.txt 中的行)分开。我知道这一定可以通过以下方法实现:
fc mount.txt mount2.txt >out.txt
for /F "tokens=*" %%A in (out.txt) do (
::separate Line)
fc 命令的输出如下所示:
Comparing files mount.txt and MOUNT2.txt
***** mount
ITCMDLogo
CBS
***** MOUNT2
Logo
ITCMDSecondLogo
CBS
*****
***** mount
MozillaPlugins
Acknowledgements
ReadMe\Palemoon-Portable-license.txt
***** MOUNT2
MozillaPlugins
ReadMe\Palemoon-Portable-license.txt
*****
我对如何确切地做到这一点感到很困惑,因为我对for /f
循环和来说还是一个初学者setlocals
。
答案1
不要使用 fc,而要使用 findstr 和以下选项:
/V Prints only lines that do not contain a match.
/I Specifies that the search is not to be case-sensitive.
/B Matches pattern if at the beginning of a line.
/E Matches pattern if at the end of a line.
/G:file Gets search strings from the specified file(/ stands for console).
您只需一个/
> findstr /VIBELG:mount.txt <mount2.txt
Logo
ITCMDSecondLogo