如果它是 0 或空的,我如何跳过第一行

How do I skip the first line if its a 0 or empty

get-childitem -path $csvfolder *.inv | get-content | add-content $outputfile

如果 inv 文件的第一行是 0,我想跳过它,但如果只有 1 行,那么我想复制它。

关于如何做到这一点有什么建议吗?

根据测试,我认为这就是您要找的东西。

Get-ChildItem -path $csvfolder *.inv | Select -Expand Fullname | ForEach-Object{
    $singleFile = @(Get-Content $_)
    If($singleFile[0] -eq "0" -and $singleFile.Count -gt 1){
        $singleFile | Select-Object -Skip 1
    } Else {
        $singleFile
    }
} | add-content $outputfile

如果 $singleFile 的第一行是 0 并且文件有多行,则跳过 0。我觉得您可能正在寻找其中包含 0 的行,但您可以告诉我这是否适合您。否则文件只是像往常一样通过管道发送。