【发布时间】:2011-11-18 07:09:36
【问题描述】:
我在.bash_aliases中定义了以下函数
findphp () {
find -name '*.php' -exec grep -H --color "$@" "{}" \;
}
它允许我运行 findphp 'function x' 之类的东西来查找 php 文件中对 function x 的所有引用
现在我想将文件类型传递给搜索,例如js,css,ctp作为bash中的参数
我定义了以下函数并获取了 .bash_aliases
myfind () {
find -name '*.$1' -exec grep -H --color "$2" "{}" \;
}
但它不起作用,我尝试了单引号,位置参数周围的双引号 无济于事。
如何定义一个函数,将文件扩展名和搜索字符串作为命令行参数?
【问题讨论】:
标签: bash shell parameter-passing