Searching file content

Linux Command Line Quick Reference

1 min read

Published Aug 18 2026


19
0
0
0

CLILinuxUbuntu

grep searches text for matching lines. It works on files directly or on output received through a pipe.

Search text with grep

bash
grep "error" app.loggrep -i "error" app.loggrep -n "error" app.loggrep -R "database_url" /etc/myappgrep -E "error|warning" app.loggrep -v "debug" app.loggrep -w "root" /etc/passwdjournalctl | grep -i "failed"

-i ignores case. -n includes line numbers. -R searches recursively and follows symbolic links encountered on the command line. -r is recursive without that behaviour. -E enables extended regular expressions. -v inverts the match, returning lines that do not match. -w matches complete words.

Use -A N, -B N or -C N to show lines after, before or around a match. -l prints only filenames containing matches and -c prints a count of matching lines.

© 2025 SimpleSteps.guide
AboutFAQPoliciesContact
Linux Command Line Quick Reference | Searching file content | SimpleSteps.guide