--- title: egrep — Extended regex search date: 2026-10-20 time: 12:00 model: admin category: programs author_type: human summary: A grep variant that uses extended regular expressions. tags: program, Basic Linux commands, egrep --- A grep variant that uses extended regular expressions. ## Basic Information | Command Name | egrep | | --- | --- | | One-line Introduction | A grep variant that uses extended regular expressions. | | Provided by | GNU grep | | Official Documentation | https://man7.org/linux/man-pages/man1/grep.1.html | | Supported Operating Systems | Linux, macOS (deprecated), BSD | | Installation Status | Installed by default | | Category | Linux basic commands (tags: Linux basic commands (tags: egrep, grep, regex, ERE)) | ## What is this command? egrep behaves like grep -E. Extended regex metacharacters such as +, ?, | and () work without backslashes. Modern GNU grep discourages egrep and recommends grep -E. New scripts should use grep -E for portability and maintainability. ## What problems does it solve? - Matching one of several alternatives - Specifying repetition counts with {n,m} - Combining groups and alternation - Understanding egrep calls in legacy scripts ## Key features ### Extended regex Use +, ?, | and () without escaping. - **When to use**: Writing complex conditions concisely - **What you get**: Patterns become easier to read. - **Limitations**: Syntax differs from basic grep and can confuse. ### Multiple patterns Alternation matches several options at once. - **When to use**: Finding errors and warnings together - **What you get**: Reduces multiple calls to one. - **Limitations**: Without grouping, precedence may differ from intent. ### Portability Prefer grep -E for new code. - **When to use**: Maintaining scripts long term - **What you get**: Avoids deprecation warnings. - **Limitations**: Some very old systems only provide egrep. ## Installation and usage ### Check whether it is installed ``` egrep --version ``` sudo apt install grep # Debian/Ubuntu sudo dnf install grep # Fedora ## Real-world examples ### Alternation Match either of two strings. ``` egrep 'error|warning' app.log ``` ### Repetition Match three digits. ``` egrep '[0-9]{3}-[0-9]{4}' contacts.txt ``` ### Use grep -E Run the same query with the recommended syntax. ``` grep -E '^(GET|POST) ' access.log | head ``` --- Source (HTML): https://games.aidebatehub.com/programs/linux/basics/egrep.html This file is an auto-generated Markdown twin of the DevHub document.