fork download
  1. #!/bin/bash
  2.  
  3. awk -v RS='abc ' '$1 == "def" {print RT $0}'
  4.  
Success #stdin #stdout 0.01s 5520KB
stdin
abc xyz 123
  this is text
  i dont need
abc def 123
  this is text
  i want to keep
and this also
{
contains
}
these lines

 xyz
xyz

abc def ppp
  this is also text
  i want to keep
abc fff
  this is text
  i dont need
stdout
abc def 123
  this is text
  i want to keep
and this also
{
contains
}
these lines

 xyz
xyz


abc def ppp
  this is also text
  i want to keep