bsearch - James Ridgway
James Ridgway - Software Engineer

bsearch

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.

Features

  • 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

Usage

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

Installing

Install manually using the compiled binaries or follow the instructions specific to your operating system.

Binaries

Download binaries:

You can also download and compile from source.

Debian/Ubuntu

# 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