Pipe output to use as the search specification for grep on Linux

前端 未结 9 1140
天涯浪人
天涯浪人 2021-02-03 22:12

How do I pipe the output of grep as the search pattern for another grep?

As an example:

grep   | xargs grep          


        
9条回答
  •  一个人的身影
    2021-02-03 22:53

    I tried this way , and it works great.

    [opuser@vjmachine abc]$ cat a
    not problem
    all
    problem
    first
    not to get
    read problem
    read not problem
    
    [opuser@vjmachine abc]$ cat b
    not problem xxy
    problem abcd
    read problem werwer
    read not problem  98989
    123 not problem 345
    345 problem tyu
    
    [opuser@vjmachine abc]$ grep -e "`grep problem a`" b --col
    not problem xxy
    problem abcd
    read problem werwer
    read not problem  98989
    123 not problem 345
    345 problem tyu
    
    [opuser@vjmachine abc]$ 
    

提交回复
热议问题