Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的 .bashrc 中有这个命令
mygrep() { find /var/www/site1 -exec grep -Hn "$1" {} \; }
但有时它不会返回结果
但是这个命令返回完整的结果
grep -r "serch term" /var/www/site1
上述功能有什么问题
在我的 Linux 机器上运行时,您的功能没有任何问题。要使结果看起来完全一样,请将-n选项添加到两个 grep 调用:grep -rn "serch term" /var/www/site1.
-n
grep -rn "serch term" /var/www/site1
这就是我在运行中比较两个命令的输出(在 bash 中)所做的:
diff <(grep -rn ast /var/www/site1) <(mygrep ast)