Skip to main content

Fast file finder and grep tool - combines find and grep functionality

Project description

ffgrep

CI Python 3.6+ License: MIT

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.

Overview

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.

Installation

Simply clone this repository and make the script executable:

git clone https://github.com/your-username/ffgrep.git
cd ffgrep
chmod +x ffgrep.py

Optionally, create a symlink to use it system-wide:

ln -s $(pwd)/ffgrep.py /usr/local/bin/ffgrep

Usage

./ffgrep.py [options] <regex> <targets...>

Arguments

  • regex: Regular expression pattern to search for within files
  • targets: File patterns (e.g., "*.c", ".py") and/or directories to search

Options

  • -i, --ignore-case: Case insensitive search
  • -l, --line-numbers: Show line numbers
  • -n, --filename-only: Show only filenames that contain matches

Examples

# 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

Features

  • 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 (.c expands 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

Requirements

  • Python 3.6+
  • No external dependencies

License

MIT License - see LICENSE file for details.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

Exit Codes

  • 0: Matches found
  • 1: No matches found or error occurred

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ffgrep-1.0.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ffgrep-1.0.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file ffgrep-1.0.0.tar.gz.

File metadata

  • Download URL: ffgrep-1.0.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for ffgrep-1.0.0.tar.gz
Algorithm Hash digest
SHA256 fe5db9382e307a3ecab61d9d1bc26f82a6e6931d83400a7d373c002d655cea08
MD5 37f24f65d287001ae4717394bcb99623
BLAKE2b-256 d4f3e04a72b4b47f686e7c32761b010d2da510c187cf9e52d6ea3382a9b88351

See more details on using hashes here.

File details

Details for the file ffgrep-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: ffgrep-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for ffgrep-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8338759700e52d8048e3f6294789665d9e694ce989682cf17d972fe3b4052599
MD5 af9ed03845ec247851e3197178ab569e
BLAKE2b-256 da2d51be953d49b6f76c3f540ab3021333d4bbdc821b262d977047c8a85a7b15

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page