A command-line utility for efficiently searching timestamps in large log files using binary search algorithms.
Bisect helps you quickly find specific timestamps in chronologically ordered log files without having to scan the entire file. It uses binary search to locate timestamps, making it particularly useful for analyzing large log files.
- Binary search for efficient timestamp location in large files
- Flexible time range parsing with offset modifiers (+, -, ~)
- Multiple time units supported (seconds, minutes, hours, days)
- Verbose output for debugging and detailed information
- Robust error handling with clear error messages
makemake installThis will copy the binary to /usr/local/bin/bisect.
bisect [OPTIONS] <filename>filename- Input log file to process (must be chronologically ordered)
-h, --help- Show help message-v, --version- Show version information-t, --time TIME- Target time to search for (required)-V, --verbose- Enable verbose output
The basic time format is: YYYY-MM-DD HH:MM:SS
You can specify time ranges using these modifiers:
+Xu- Search forward from time by X units-Xu- Search backward from time by X units~Xu- Search both directions (±X units from time)
Where u is one of:
s- secondsm- minutesh- hoursd- days
# Find exact timestamp
bisect -t "2025-06-02 11:55:34" application.log
# Find entries within 30 seconds after timestamp
bisect -t "2025-06-02 11:55:34+30s" application.log
# Find entries from 1 hour before timestamp
bisect -t "2025-06-02 11:55:34-1h" application.log
# Find entries within 2 hours before and after timestamp
bisect -t "2025-06-02 11:55:34~2h" application.log
# Verbose output
bisect -V -t "2025-06-02 11:55:34" application.log- Log files must contain timestamps in
YYYY-MM-DD HH:MM:SSformat - Timestamps must be in chronological order
- Files must be readable by the user
make # Build release version
make debug # Build debug version with symbols
make test # Build and run tests
make clean # Clean build artifactsThe project includes comprehensive unit tests:
make testTests cover:
- Time string parsing and validation
- Range calculation with various modifiers
- Error handling for invalid inputs
- Edge cases and boundary conditions
main.c- Command-line interface and argument parsingbisect_lib.c- Core binary search and file processing logicsearch_range.c- Time range parsing and validationtest.c- Unit tests*.h- Header files with function declarations
This project is open source.