A simple utility written in Go for quickly and efficiently searching a sorted file for lines that start with a given search key.
bsearch uses binary search which relies on the file being sorted in either ascending or descending order. This approach is capable of searching tens of gigabytes of data in milliseconds.
- Case insensitive searching
- Trim whitespace from the start of the search key and/or lines in the file
- Support numeric searching
- Support ascending/descending sort order
NAME: bsearch - utility for binary searching a sorted file for lines that start with the search key USAGE: bsearch [options] SEARCH_KEY FILENAME VERSION: 1.0.2 COMMANDS: help, h Shows a list of commands or help for one command GLOBAL OPTIONS: -r, --reverse the reverse flag indicates the file is sorted in descending order -i, --ignore-case case insensitive -t, --trim ignore whitespace -n, --numeric use numeric comparison --help, -h show help --version, -v print the version
Install manually using the compiled binaries or follow the instructions specific to your operating system.
- Linux: bsearch-linux-x86_64-1.0.2.tgz
- Windows: bsearch-windows-x64-1.0.2.zip
- macOS: bsearch-macOS-x64-1.0.2.tgz
You can also download and compile from source.
# Add Bintray's GPG key sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 379CE192D401AB61 # Add the repository echo "deb https://dl.bintray.com/jamesridgway/debian xenial main" | sudo tee -a /etc/apt/sources.list # Update apt sudo apt-get update # Install sudo apt-get install bsearch