chaf – Not a finder. A filter.
✨ What is chaf?
chaf is a text filtering tool with the following features:
- Logical expressions for condition specification
- Instead of "searching" like
grep, it "excludes" specified lines - Supports standard input/output, making it pipe-friendly
- Uses stdin when no input file is provided
- Invert exclusion with
--invertto act likegrep - Display summary report with
--report - Not as fast as
grep, but can process ~10 million lines in a few seconds
💡 Why was it created?
While grep -v is convenient, expressing complex exclusion rules becomes unreadable.
For example: "Exclude DEBUG, but keep [DEBUG] connect DB"
Such conditions are difficult to express clearly with grep.
chaf lets you write exclusion logic with logical expressions — a filter dedicated to exclusion.
🖥️ Example Usage
## 🖥️ Example Usage
🚀 Installation
The chaf binary will be placed in:
If your PATH doesn't include that directory, add it like so:
✔ Command-Line Interface
chaf [OPTIONS] <QUERY> [FILE]
📝 Query DSL (Logical Filter Language)
| Syntax | Meaning |
|---|---|
aaa & bbb |
AND — match lines containing both aaa and bbb (exclude) |
aaa | bbb |
OR — match lines containing either aaa or bbb (exclude) |
!aaa |
NOT — match lines not containing aaa (exclude) |
(aaa | bbb), (aaa & bbb) |
Use parentheses to group and control precedence |
Operator Precedence
1. Parentheses "()"
2. NOT "!"
3. AND "&"
4. OR "|"
🎛️ Available Options
| Option | Description |
|---|---|
--report, -r |
Show summary: total lines, excluded lines, output lines |
--invert, -i |
Invert filter to show matching lines only (like grep) |
--help, -h |
Show help message |
--version, -v |
Show version information |
Tip: You can redirect output to a file with > if needed.
🙌 Contributing
Contributions for improvements or feature expansions are very welcome!
Feel free to open an issue or PR if you have any feedback or suggestions —
no matter how small, we'd love to hear from you.
🔮 Planned Features
- Wildcard support (
*,?) for more flexible pattern matching
✅ License
This project is dual-licensed under:
- MIT License
https://opensource.org/licenses/MIT - Apache License 2.0
https://www.apache.org/licenses/LICENSE-2.0
Use whichever license suits your needs.