gpt4 book ai didi

powershell - 管道文件以获取内容

转载 作者:行者123 更新时间:2023-12-04 17:52:32 24 4
gpt4 key购买 nike

我正在尝试使用 powershell 递归地找到一行代码。

要在已知文件中查找“TODO”行,我可以执行以下操作:

get-content ActivityLibrary\Accept.cs | select-string TODO

但我不想明确键入每个目录\文件。我想像这样从 get-childitem 管道一系列文件名:
gci -filter *.cs -name -recurse | gc | select-string TODO

但后来我看到了这个错误:

Get-Content : The input object cannot be bound to any parameters for the comman d either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input. At line:1 char:37



我究竟做错了什么?

最佳答案

您需要删除 -Name 开关。它只输出文件名,不输出文件对象。您也可以直接通过管道连接到 Select-String 并删除 'gc'。

关于powershell - 管道文件以获取内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13916650/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com