修改了findByContent函数,简化了参数设计。现在该函数只接受一个参数(模式),在当前目录及其子目录下搜索文件内容。
@@ -236,9 +236,8 @@ function findByName() {
find . -name "*$pattern*"
}
function findByContent() {
- local pattern=$2
- local dir=$1
- find $dir -type f -exec grep -l "$pattern" {} +
+ local pattern=$1
+ find . -type f -exec grep -l "$pattern" {} +
# 备份