title: How to use pipe within -exec in find
body: <p>Is there any way to use pipe within an -exec in find? I don't want grep to go through whole file, but only through first line of each file.</p>
  
  <pre><code>find /path/to/dir -type f -print -exec grep yourstring {} \;
  </code></pre>
  
  <p>I tried to put the pipelines there with "cat" and "head -1", but it didn't work very well. I tried to use parenthesis somehow, but I didn't manage to work out how exactly to put them there.
  I would be very thankful for your help. I know how to work it out other way, without using the find, but we tried to do it in school with the usage of find and pipeline, but couldn`t manage how to. </p>
  
  <pre><code>find /path/to/dir -type f -print -exec cat {} | head -1 | grep yourstring \;
  </code></pre>
  
  <p>This is somehow how we tried to do it, but could't manage the parenthesis and wheter it is even possible. I tried to look through net, but couldn' t find any answers.</p>