root-hunter / zig-search

High-performance search utility written entirely in Zig

Repository from Github https://github.comroot-hunter/zig-searchRepository from Github https://github.comroot-hunter/zig-search

MIT License LinkedIn


Logo

zig-search

High-performance search utility written entirely in Zig

About The Project

This is my first project written in Zig. I've been fascinated by Zig and its features, which offer a unique blend of performance, simplicity, and control. Zig-Search is a testament to the power and efficiency that Zig brings to the table, and it has been an exciting journey exploring what this language can do. I hope this tool showcases the potential of Zig and inspires others to explore it as well.

Features

  • 100% Zig implementation
  • Only std lib
  • Fast and efficient directory scanning
  • Recursive search in nested directories
  • Simple command-line interface

Getting Started

This is an example of how you may give instructions on setting up your project locally. To get a local copy up and running follow these simple example steps.

Build Prerequisites

These are the prerequisites needed only to build the project, if you only want to use zig-search you can go to the Usage section

Build

  1. Clone the repo
git clone https://github.com/root-hunter/zig-search
  1. Move to zig-search dir
cd zig-search
  1. Build executable
make build-exe

or

zig build-exe src/main.zig --name zig-search -static

(back to top)

Examples

Search and export into file all path of files (with extension .txt) that contains the word "password" at least one time.

zig-search /start/path "password" -f txt -e ${HOME}/Documents/zig-search_result.txt

Search and export into file all path of files (with extension .txt, .js, .html) that contains the word "password" at least one time.

zig-search /start/path "password" -f txt,js,html -e ${HOME}/Documents/zig-search_result.txt

Search and export into file all path of files (with extension .txt) that contains the word "password" at least one time using 16 threads.

zig-search /start/path "password" -f txt -t 16 -e ${HOME}/Documents/zig-search_result.txt

Search and export into file all path of files (with extension .txt) that contains the word "password" at least one time using all possible threads.

zig-search /start/path "password" -f txt -t 0 -e ${HOME}/Documents/zig-search_result.txt

Only print paths to console without export result file (using all cpu core).

zig-search /start/path "password" -f txt -t 0

Active case sensitive search.

zig-search /start/path "Password" -f txt -t 0 -c

Help command.

zig-search --help

Usage: zig-search START_PATH SEARCH_STRING [OPTIONS]...

Options:
  --help                           Help command
  -f, --file-extensions            File extensions, in this form: txt,js | js,c,cpp
  -t, --thread-count               Scan thread count (Default: 1)
  -a, --all-match                  Match all the occurence in the file (Default: false)
  -c, --case-sensitive             Case sensitive search (Default: false)
Export options:
  -e, --export-path                File export path (ABSOLUTE)
  --export-no-info                 Disable info header in the export file
  --export-match-position          Add match position info for each path in the export file

(back to top)

Roadmap

  • Help command
  • Multihreading
  • Advance text search
  • Export results to file
  • Scan file by list file paths

(back to top)

License

Distributed under the MIT License. See LICENSE for more information.

(back to top)

About

High-performance search utility written entirely in Zig

License:MIT License


Languages

Language:Zig 96.8%Language:Makefile 3.2%