Skip to main content

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

Project description

ffgrep

CI Pylint 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.1.0.tar.gz (6.4 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.1.0-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for ffgrep-1.1.0.tar.gz
Algorithm Hash digest
SHA256 818a215a25549e0d1be015c0d96f41b412c6320aced7749ba0f73df49b118a96
MD5 998ec7a2e47f78f0901a24c0f1aa3c5d
BLAKE2b-256 77ca483068d5ea3fdf7bc1c7a12f45b419f8f84b2cce66232560fd3a7da8d2cc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ffgrep-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.6 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 28f75a4fd3d621b15ee94c08b029ea00e81bd5862555735ac22e5637fc51e4b8
MD5 3b6bb8790ffbea053dc1f4b939c9f884
BLAKE2b-256 a2bc0062058d60fc3e96d722d8a53d40a14114bda2c4e2c5dd31fe6ae51ff343

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