2018年4月18日 星期三

[Linux 常見問題] How to do max-depth search in ack and grep?

Source From Here 
Question 
Is there any way to tell ack to only search for text on the current folder? (or specify a max-depth level?) And with grep

How-To 
Use -n for no-recurse: 
# ack -n foo

grep is not recursive by default, and you should use the -r flag only if you want a recursive search. Another way to search with max depth limitation is by adopting command find. For example: 
// -H, --with-filename
Print the file name for each match. This is
the default when there is more than one file
to search.

# find Github/ -maxdepth 2 -type f -exec grep -H 'test' {} \;

Supplement 
Home > Blog Tutorial: How to Use Ack and Grep on Ubuntu 14.04

沒有留言:

張貼留言

[Git 常見問題] error: The following untracked working tree files would be overwritten by merge

  Source From  Here 方案1: // x -----删除忽略文件已经对 git 来说不识别的文件 // d -----删除未被添加到 git 的路径中的文件 // f -----强制运行 #   git clean -d -fx 方案2: 今天在服务器上  gi...