Filter

Keep error lines

Keep only lines that contain error or ERROR.

What this template solves

This long-tail template focuses on a common debugging workflow: extracting only error lines from a noisy log or text export.

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

Sample input

INFO boot
ERROR db failed
warn retry
error timeout

Prompt to start from

Keep only lines that contain error in the log file

Expected command

sed -n '/[Ee][Rr][Rr][Oo][Rr]/p'

Tags

filterlogserrorsdebugging

Best for

  • Extract only error rows from mixed application logs.
  • Create a concise failure-only report from large text output.
  • Filter logs before sharing them with teammates or support.

How to use this template

  1. 1Confirm whether the file uses error, ERROR, or another repeated failure keyword.
  2. 2Use the keep-error-lines sed filter as the starting point.
  3. 3Adjust the pattern in AskSed if needed, then run the filtered or file-edit workflow.

Template FAQ

What is the simplest sed command to keep only error lines?

A typical starting point is `sed -n '/error/p'`, which prints only lines containing the keyword. You can then refine the pattern for uppercase variants, exact words, or specific log formats inside AskSed.

Why is keep-error-lines worth a dedicated long-tail template page?

Because extracting only error lines is a repeated real-world debugging need. It has clear search intent, specific command patterns, and strong relevance for developers scanning noisy logs.

Related templates

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

Keep error lines Sed Template | AskSed