Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

6
  • Thanks for the response. So basically it say if i run ** find . -name "ABC" -exec grep -H 'XYZ' {} + ** and it give me 2 files then the command line will be like ** grep -H 'XYZ' ABC.txt;grep -H 'XYZ' ABC2.txt ** Feel free to correct me if I am wrong. Commented Jul 25, 2018 at 8:21
  • 2
    No, the command line would be grep -H 'XYZ' ABC.txt ABC2.txt. You’d get the equivalent of grep -H 'XYZ' ABC.txt; grep -H 'XYZ' ABC2.txt if you used ; instead of +. Commented Jul 25, 2018 at 8:22
  • One last question but not the least. How to write code if I want to pipe the output of 1st grep to another grep. I tried this code find . -name "ABC" -exec grep -H 'XYZ' {}|grep -v 'DEF' + But give me error. Commented Jul 25, 2018 at 8:41
  • find . -name "ABC" -exec grep -H 'XYZ' {} + | grep -v 'DEF' Commented Jul 25, 2018 at 8:45
  • 1
    find -exec {} + has been introduced by David Korn in 1989, but it was undocumented until 1995 when it was added to POSIX. The people from the GNU universe rarely know it since GNU find was the last find implementation that added support for it, so people from that universe frequently use the inferior and vendor unique -print0. Commented Jul 25, 2018 at 9:22