title: command to print all the lines until the first match
body: <p>I am trying to print all the lines from a file before the first match. I have the same entries again in the file, but I don't need that lines. Tried
  awk "{print} /${pattern}/ {exit}" and sed "/$pattern/q" (my serach is based on a variable). But both these commands are printing all the line before the last match
  ex: my file is like
  abc
  bcd
  def
  xyz
  def
  lmno
  def
  xvd</p>
  
  <p>when my pattern is 'def', i just need abc and bcd . but the above commands are printing, all the lines before the last 'def'. could you please provide some idea</p>