title: UNIX: Using egrep or sed to find the line with the first occurrence of a string?
body: <p>I am working in a bash shell and I am trying to print only the line of the first occurrence of the string. For example, for the string '<code>auir</code>', if I have the file myfile.txt and it contains:</p>
  
  <pre><code>123
  asdf
  4wirajw
  forauir somethingelse
  starcraft
  mylifeforauir
  auir
  something else
  tf.rzauir
  </code></pre>
  
  <p>I want to output "<code>forauir somethingelse</code>"</p>
  
  <p>So far, I use the command</p>
  
  <pre><code>sed -n '/auir/p' myfile.txt
  </code></pre>
  
  <p>which gives me all the occurrences of this string. How can I only get the first line that '<code>auir</code>' occurs on? It'd be great if it was just a single command or pipeline of commands.</p>
  
  <p>Any insight is greatly appreciated.</p>