fork download
  1. #!/bin/bash
  2. input_exmpl='foo\nbar\nfoo bar\nbar foo\nbbar foo'
  3.  
  4. echo -e $input_exmpl
  5. echo '--------------'
  6. echo -e $input_exmpl | grep -Pn '^(?=.*\bfoo\b)(?=.*\bbar\b)'
  7.  
Success #stdin #stdout 0.01s 5512KB
stdin
Standard input is empty
stdout
foo
bar
foo bar
bar foo
bbar foo
--------------
3:foo bar
4:bar foo