gpt4 book ai didi

command-line - 如何使 findstr 显示内联的完整文件路径?

转载 作者:行者123 更新时间:2023-12-01 22:28:48 26 4
gpt4 key购买 nike

当我使用 grep 时,我得到了一个匹配结果列表,其中包含所有子目录的完整文件路径。

当我使用 findstr 执行此操作时 - 我没有得到内联结果。

我的问题是:如何让 findstr 显示内联的完整文件路径?

最佳答案

在综合 List of undocumented features and limitations of FINDSTR 中阅读 FINDSTR 输出Dave Benham 又名 dbenham :

... When printed, the fileName will always include any path information provided. Additional path information will be added if the /S option is used. The printed path is always relative to the provided path, or relative to the current directory if none provided.

因此,提供绝对路径。例如:代替

findstr /S /M /I /C:"string being searched for" *.txt

使用

findstr /S /M /I /C:"string being searched for" "%CD%\*.txt"

当然,上面示例中给出的所有 /S/M/I/C: 开关都是可选的:

d:\bat\files>findstr "success" *.txt
netuser.txt:The command completed successfully.
typeperf.txt:The command completed successfully.

d:\bat\files>findstr "success" "%CD%\*.txt"
d:\bat\files\netuser.txt:The command completed successfully.
d:\bat\files\typeperf.txt:The command completed successfully.

关于command-line - 如何使 findstr 显示内联的完整文件路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30542961/

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