gpt4 book ai didi

bash - 有别名的 shell/bash 方法吗? -type f -exec grep -l <​​这里的一些词> {}\;;

转载 作者:行者123 更新时间:2023-12-04 16:16:48 25 4
gpt4 key购买 nike

基本上,此命令对所有子目录中的所有文件执行递归 grep,我经常使用它

但是它太长了,打字需要一段时间

所以我想知道是否...

$ find . -type f -exec grep -l <some word here> {} \;;

有一种方法可以在我的 .bashrc 中为其添加别名或其他内容,这样我就可以做类似...的事情

$ findrecursive <some word here>

最佳答案

我只是假设你使用 Linux 和 GNU 工具,我不知道它是否是 GNU 扩展,否则下面的代码片段应该做你想做的,快速和简单:

grep -r <search-regexp>

以上不遵循符号链接(symbolic link),如果您希望您的搜索做到这一点,您需要:

grep -R <search-regexp>

在某些发行版中有一个 rgrep 命令,我只是认为它是 grep -r 的别名。如果您没有它,只需执行 alias rgrep="grep -r" 并将其放入您的 .bashrc 或等效文件中。

关于bash - 有别名的 shell/bash 方法吗? -type f -exec grep -l <​​这里的一些词> {}\;;,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12334782/

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