gpt4 book ai didi

Linux 外壳 : How to give parameter to alias of find command?

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:56:05 26 4
gpt4 key购买 nike

例如,我希望为所有名为“Makefile”的文件查找当前目录(不包括 ./bin),作为参数和 grep“library”,如下所示:

find . ! -path "./build" -name "*Makefile"|xargs grep library

我不想每次都输入所有这些,我只想创建一个带有 2 个参数的“别名”,例如:

myfind "*Makefile" "library"

myfind 的 find 参数是 find 命令的 name,grep 命令的第二个参数,我也希望星号“*”可以作为参数的一部分传递,而不被解析。

这样的别名怎么写?

最佳答案

使用函数:

myfind() { find . ! -path "./build" -name "$1"|xargs grep "$2"; }

关于Linux 外壳 : How to give parameter to alias of find command?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41442277/

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