bash - command to print all the lines until the first match -


I am trying to print all the lines from the file before the first match. I have only one entry in the file, but I do not need that line, weird "{print} / $ {pattern} / {exit}" and tried the "/ $ pattern / q" (my search on a variable is based). But both the commands are printing all the lines before the last match: My file is like ABC BCD Def Ex A Def LMN Def XVD

When my pattern is 'def', I need ABC and BCD But the above orders are printing, all the lines before the last 'DF' can you please provide some ideas.

This should work:

  awk '!' / $ {Pattern} / {print} / $ {pattern} / {exit} "input_file.txt  

Comments

Popular posts from this blog

HTML/CSS - Automatically set height width from background image? -

php - Mysql Show Process - Sleep Commands and what to do -

c - What is the address of buf (the local variable in the main function)? -