A command-line utility for searching text files using pattern recognition. Pattern-Seek helps you find specific types of data like emails, GUIDs, dates, URLs, and IP addresses within your files.
As the project evolves, I'll add more features, improve the code, tests, and documentation.
Currently, it only supports plain text files/files that can be encoded in UTF-8. Other formats are currently not supported, and feedback on how to support is much welcome.
- Pattern-based search: Find various data types using regex patterns
- GUID/UUID
- Email addresses
- Dates (multiple formats)
- URLs
- IP addresses (IPv4 and IPv6)
- Regular text search: Find any text string with customizable options
- Case-sensitive matching
- Whole word matching
- Multi-file/directory search: Search across individual files, multiple files, directories, or with wildcards
- Context display: Show surrounding lines for each match
- Colored output: Highlight matches with color coding
- Flexible CLI: User-friendly command-line interface
- Python 3.8 or higher
# Clone the repository
git clone https://github.com/mubbie/pattern-seek.git
cd pattern-seek
# Create a virtual environment (optional but recommended)
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install the package
pip install -e .
# Basic usage: search all supported patterns in a file
pattern-seek filename.txt
# Search for specific pattern types
pattern-seek --pattern email --pattern url filename.txt
# Search for regular text
pattern-seek --pattern text --text "def" *.py
# Case-sensitive text search
pattern-seek --pattern text --text "Class" --case-sensitive src/*.py
# Whole word text search
pattern-seek --pattern text --text "import" --whole-word *.py
# Search with context lines
pattern-seek --pattern email --context 2 filename.txt
# Search multiple files
pattern-seek file1.txt file2.txt
# Search all Python files in current directory
pattern-seek *.py
# Search recursively in a directory
pattern-seek /path/to/directory/
# Show help
pattern-seek --help
Option | Short | Description |
---|---|---|
--pattern |
-p |
Pattern types to search for: email, guid, date, url, ip, text, all (default) |
--text |
-t |
Text pattern to search for when using the "text" pattern type |
--case-sensitive |
-c |
Make text search case-sensitive |
--whole-word |
-w |
Match whole words only for text search |
--context |
-C |
Number of context lines to include before and after matches |
--no-color |
Disable colored output | |
--help |
-h |
Show help message |
pattern-seek --pattern email --context 2 application.log
pattern-seek --pattern guid --pattern ip *.py
pattern-seek --pattern text --text "def main" *.py
pattern-seek --pattern text --text "Class" --case-sensitive --whole-word src/*.py
pattern-seek --pattern url --pattern date /path/to/project/
# Install development dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Run tests with coverage
pytest --cov=pattern_seek
MIT
Contributions are welcome! Please open an issue or submit a pull request.
You can see the development plan and features planned for future versions in the plan.md file.
Each version has its own dedicated change log file. You can see the change log for the latest version in the change-log/v0.1.0.md file.
I'd love to hear from you! Please open an issue, submit a pull request, or contact me directly at [email protected].