PRBLEM / DEVELOPER RESOURCES

Bash grep -n

← Back to Code Library

BashBeginner

Find matching lines and show line numbers.

When to use it

Use to inspect logs or text files.

Bash · Editable example
No visitor code executes on the WordPress server.
Edit this example or check its structure. For Python/SQL select Run for real browser-based output.

Expected output

2:beta

Common mistake and fix

Quote patterns that contain shell special characters.

Related concepts: pipes, filters

Explain this code

Find matching lines and show line numbers.

Educational examples are not a substitute for a real compiler or version-specific documentation. JavaScript, Python and SQLite demos run in isolated browser contexts when supported; Python and SQL load an online WebAssembly runtime on first use. Other languages receive structural hints, not compiler validation. No visitor code executes on WordPress.