A fast file finder and grep tool that combines the functionality of find and grep into a single command.
Developed with assistance from Claude AI by Anthropic.
ffgrep replaces the common pattern of find . -name '*.ext' | xargs grep pattern with a simpler, more efficient command. It recursively searches for files matching a pattern and greps for content within those files.
Simply clone this repository and make the script executable:
git clone https://github.com/your-username/ffgrep.git
cd ffgrep
chmod +x ffgrep.pyOptionally, create a symlink to use it system-wide:
ln -s $(pwd)/ffgrep.py /usr/local/bin/ffgrep./ffgrep.py [options] <regex> <targets...>regex: Regular expression pattern to search for within filestargets: File patterns (e.g., "*.c", ".py") and/or directories to search
-i, --ignore-case: Case insensitive search-l, --line-numbers: Show line numbers-n, --filename-only: Show only filenames that contain matches
# Find 'main' function in all C files
./ffgrep.py main "*.c"
# Extension shorthand - .c expands to *.c
./ffgrep.py CONFIG_HIGHMEM .c
# Case-insensitive search for test functions in Python files
./ffgrep.py "def.*test" "*.py" -i
# Show line numbers for error messages in log files
./ffgrep.py error "*.log" -l
# Search multiple file types
./ffgrep.py error "*.log" "*.txt" -l
# Search in multiple directories
./ffgrep.py main "*.c" src/ tests/
# Just show filenames containing TODO comments
./ffgrep.py TODO "*.py" -n- Fast: Uses generators to avoid loading all file paths into memory
- Flexible: Supports multiple file patterns and directories in a single command
- Smart: Extension shorthand (
.cexpands to*.c) - Powerful: Full regex support for content search
- Portable: Single Python script with no external dependencies
- Unix-friendly: Follows Unix conventions for exit codes and output format
- Python 3.6+
- No external dependencies
MIT License - see LICENSE file for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
0: Matches found1: No matches found or error occurred