Grep 命令语法如下:
grep "literal_string" filename --> search from string in filename.
所以我假设的顺序是这样的
-- keyword(grep) --> string to be searched --> filename/source string and command is interpreted from left to right.
我的问题是如何处理这样的命令:
ps -ef | grep rman
订单是可选的吗?
grep 如何知道源位于左侧而不是右侧?或者我在这里遗漏了一些东西。
最佳答案
使用 Unix 管道时,大多数系统命令将从前一个命令(管道左侧)获取输出,然后将输出传递到管道右侧的命令。
使用带有或不带有管道的 grep 时,顺序很重要。
因此
grep doberman /file/about/dogs
与
相同cat /file/about/dogs | grep doberman
请参阅 http://linuxcommand.org/lts0060.php 上的管道了解更多信息。
关于linux - Grep 命令 Linux 源字符串和目标字符串的排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29378055/