Harness the speed of grep to filter command output and files with precision. 15.11.2025 | reading time: 2 min On the command line the tool `grep` lets a user filter streams and files by pattern and see only the lines that matter; it is fast and simple to learn. Hands-on search Try this on a log file to find errors quickly: ```bash $ grep -n 'error' /var/log/syslog 123:Nov 10 12:34:56 host kernel: error: device not responding 456:Nov 10 12:35:01 host app: ERROR: failed to connect ``` Or filter processes and ignore the grep line: ```bash $ ps aux | grep -i 'sshd' | grep -v 'grep' root 1234 0.0 0.1 12345 678 ? Ss 10:00 0:00 /usr/sbin/sshd ``` These examples show line numbers and case-insensitive matching; run them and inspect the output. Match strategies Use options to shape the result: `-i` for case-insensitive, `-v` to invert match, `-n` to show line numbers, `-E` for extended regex and `-r` to search directories recursively; combine `--color=auto` to highlight matches and `-o` to print only the matched portion, or `-c` to count matches. Piping power Chain `grep` with other tools to answer real questions: `grep -E 'error|warn' logfile | sort | uniq -c` shows frequent issues; use `xargs` to act on files returned by `grep -l`, or hand matched fields to `awk` or `sed` for extraction and transformation. Clear next steps Start using `grep` in daily troubleshooting: search logs, inspect command output, and build small pipelines; then expand to faster or more specialized tools and consider formal study — pursue CompTIA Linux+ or LPIC-1 and try intensive exam prep at bitsandbytes.academy to level up. Join Bits & Bytes Academy First class LINUX exam preparation. utilities scripting troubleshooting