【问题标题】:Compare 2 text files and display the difference between them (PowerShell or CMD)比较 2 个文本文件并显示它们之间的差异(PowerShell 或 CMD)
【发布时间】:2015-08-26 04:23:11
【问题描述】:

我有 2 个文本文件 text1.txt 包含:

fc1/1 storage
fc1/5 switch
fc1/7 replication

text2.txt 包含:

fc1/1 storage
fc1/5 nas
fc1/7 replication

我想要一个脚本,它比较两个文本文件并生成在 text2.txt 上找到的文本,但在名为 difference.txt 的文本文件中的 text1.txt 上没有生成文本

difference.txt 包含

fc1/5 nas

有什么想法吗?

【问题讨论】:

  • 这就是Compare-Object 的用途!
  • 否决“这个问题没有显示任何研究成果”
  • 我知道马特。但是我的 ps 脚本不完整。有什么想法吗?

标签: powershell command-line cmd command


【解决方案1】:

也许……

findstr /v /g:text1.txt text2.txt  > difference.txt

text2.txt 中搜索与 text1.txt 中不匹配的 (/v) 行

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-10-07
    • 1970-01-01
    • 2020-10-19
    • 2015-08-10
    • 1970-01-01
    • 2021-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多