简体   繁体   English

在linux中的自定义别名中没有得到find命令的结果

[英]Not getting result with find command in custom alias in linux

I have this command in my .bashrc 我在.bashrc中有这个命令

 mygrep() {
         find /var/www/site1 -exec grep -Hn "$1" {} \;
     }

But sometimes its not returing results 但有时它不是结果

But this command return full results 但是这个命令返回完整的结果

grep -r "serch term" /var/www/site1

whats wrong with above function 以上功能有什么问题

Nothing is wrong with your function when run on my Linux box. 在我的Linux机器上运行时,您的功能没有任何问题。 To make results look absolutely the same, add the -n option to both grep calls: grep -rn "serch term" /var/www/site1 . 要使结果看起来完全相同,请在两个grep调用中添加-n选项: grep -rn "serch term" /var/www/site1

This is what I did to compare the output of both commands on the fly (in bash): 这就是我在动态比较两个命令的输出时所做的(在bash中):

diff <(grep -rn ast /var/www/site1) <(mygrep ast)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM