Filter

Keep WARNING lines

Keep only lines that contain warning or WARN.

What this template solves

Use this long-tail template when you need to isolate warning-level output from a noisy log without keeping info or debug entries.

Open the workspace with this template preloaded, then refine it for your own file and text pattern.

Sample input

INFO boot
WARNING disk near full
WARN retrying
ERROR failed

Prompt to start from

Keep only lines that contain warning in the log file

Expected command

sed -n '/WARN\|warning/p'

Tags

filterlogswarningreview

Best for

  • Extract warning rows for review or handoff.
  • Create a focused warning-only report from large logs.
  • Filter mixed logs before comparing warning trends.

How to use this template

  1. 1Check whether the file uses warning, WARNING, or WARN as the repeated marker.
  2. 2Copy the keep-warning-lines sed filter as the starting pattern.
  3. 3Adjust the match in AskSed if needed, then run the filtered workflow on the real file.

Template FAQ

How do I keep only WARNING or WARN lines with sed?

A starting point is `sed -n '/WARN\|warning/p'`, or a stricter pattern tailored to your log format. The goal is to print only warning-level rows while suppressing everything else.

When should I use keep-warning-lines instead of keep-error-lines?

Use keep-warning-lines when you want to isolate non-fatal warning patterns, such as deprecations, retries, or performance alerts, rather than only hard failures or error rows.

Related templates

Explore nearby sed workflows that target similar replace, cleanup, filtering, or rewrite tasks.

Keep WARNING lines Sed Template | AskSed