how can I get sed to quit after the first matching address range?

You can do this with a loop in GNU sed:

sed -n '/trigger/{p; :loop n; p; /trigger/q; b loop}'

Explanation:

  1. When you see the first /trigger/, start a block of commands
  2. p — print the line
  3. :loop — set a label named loop
  4. n — get the next line
  5. p — print the line
  6. /trigger/q — if the line matches /trigger/ then exit sed
  7. b — jump to loop

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)