Blank-line-separated records can lose their context when a normal line-by-line search prints only the matching line. Use awk paragraph mode when a status, error, or field can appear inside a record that spans several lines and the output must keep the full record together.
Setting RS="" makes awk read records separated by one or more blank lines instead of one input line at a time. Setting ORS="\n\n" adds the blank line back between printed records so each matched block remains readable in terminal output or a handoff file.
The sample uses simple health-check blocks separated by empty lines. It is not a parser for JSON, YAML, quoted CSV, or application logs whose record boundary depends on nesting or escaping; use a format-aware parser for those files.
$ cat > checks.txt <<'EOF' host: web-01 status: ok service: nginx message: accepting requests host: db-01 status: failed service: postgresql message: disk space below threshold host: cache-01 status: ok service: redis message: responding to pings EOF
$ awk 'BEGIN { RS=""; ORS="\n\n" } /status: failed/' checks.txt
host: db-01
status: failed
service: postgresql
message: disk space below threshold
RS="" switches awk to paragraph-style records. The pattern still searches within the current record, but print writes the entire matched record instead of only the matching line.
Keep a real blank line between records when using RS="". If blank lines can appear inside a record, choose a record separator that matches the actual file format or use a parser built for that format.
$ rm checks.txt