【问题标题】:What does output of compare-object mean when comparing two files in powershell在powershell中比较两个文件时比较对象的输出是什么意思
【发布时间】:2015-12-01 21:23:29
【问题描述】:

下面的脚本有两个文件,但我不清楚下面的sideIndicator箭头和点的理解输出:

...

 What does the above actually mean ?

这是比较脚本:

  Compare-Object -referenceobject (Get-Content C:\Users\admin\Desktop\powershell_scripts\zz.txt) -differenceobject (Get-Content C:\Users\admin\Desktop\powershell_scripts\allstudents5.txt) -SyncWindow 100 -includeequal

AD\zpjnbb                ... <=                                                                   
AD\zhjfhg                ... <=    
                             <=                                    
                             <=   

【问题讨论】:

    标签: powershell powershell-2.0


    【解决方案1】:

    在 PowerShell 中,您可以使用 Get-Help CmdLet 了解更多信息:

    Get-Help Compare-Object -ShowWindow
    

    直接来自Description

    说明

    Compare-Object cmdlet 比较两组对象。一组对象是“参考集”,另一组是“差异 设置。”

    比较的结果表明一个属性值是否只出现在引用集中的对象中(由 符号),或者,如果指定了 IncludeEqual 参数,则在两者中 对象(由 == 符号表示)。

    注意:如果引用集或差异集为 null ($null),Compare-Object 会生成终止错误。

    一个关于逻辑的小例子:

    Compare-Object -ReferenceObject ('A', 'B') -DifferenceObject ('B','C') -IncludeEqual
    
    InputObject    SideIndicator                                            
    -----------    -------------                                            
    B              ==                                                       
    C              =>                                                       
    A              <=  
    

    更多例子你可以试试:

    Get-Help Compare-Object -Examples
    

    【讨论】:

    • 谢谢,但它是 "..." 之前的 "
    • 在答案中添加了一个示例。在这三个点上,您可以找到更多信息here
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-26
    • 2014-04-09
    • 1970-01-01
    • 2018-05-09
    • 1970-01-01
    相关资源
    最近更新 更多