gpt4 book ai didi

regex - 我如何在 linux 中使用 regex 和 locate 命令

转载 作者:可可西里 更新时间:2023-11-01 11:49:54 26 4
gpt4 key购买 nike

我想将 locate 命令与正则表达式一起使用,但我无法使用它。

我想找到/usr 文件夹中的 pip 文件。我正在尝试这个

locate -r "/usr/*pip"

最佳答案

要在查询中使用 globbing 字符,您不应指定正则表达式(就像使用 -r 选项一样),所以只需执行以下操作:

locate "/usr/*pip"

来自手册页:

If --regex is not specified, PATTERNs can contain globbing characters.If any PATTERN contains no globbing characters, locate behaves as ifthe pattern were *PATTERN*.

关于regex - 我如何在 linux 中使用 regex 和 locate 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13534459/

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