Build a Tiny “Everything” Search Tool on Linux with a One‑Line Shell Script
This guide shows how to create a lightweight, recursive file‑search script for Linux that mimics the Windows Everything tool, explains each part of the shell code, and demonstrates how to run it, enable case‑sensitivity, search specific paths, and bind it to a custom alias.
Linux users can replicate the fast file‑search capabilities of the Windows "Everything" utility by using a compact shell script called lazy_find.sh. The script leverages find with configurable options for case‑sensitive matching and path selection, providing recursive search across directories.
Script Overview
The script begins with a help function that prints usage information, then defines default variables MATCH="-iname" (case‑insensitive name match) and SEARCH="." (current directory). It parses command‑line options: --help or -h – display help. --match-case or -m – switch to case‑sensitive matching by setting MATCH="-name". --path or -p – specify a different search directory.
After option parsing, the script sanitises input, checks for missing arguments, and then iterates over each provided filename pattern, invoking /usr/bin/find with the constructed parameters.
Creating and Using the Script
1. Create the file: $ vim lazy_find.sh 2. Paste the script content and save with :wq.
3. Make it executable: $ chmod +x lazy_find.sh 4. Basic usage – search for a fragment of a filename: $ ./lazy_find.sh scr The script lists matching files in the current directory and all sub‑directories, ignoring case by default.
5. Enable case‑sensitive search by adding -m: $ ./lazy_find.sh -m scr 6. Search a specific directory with --path (or -p), e.g., the home folder for files containing "hello":
$ ./lazy_find.sh --path ~ helloBinding the Script to a Custom Command
To avoid typing the script path each time, add an alias to .bashrc:
alias lf=~/bin/lazy_find.sh # adjust the path to your scriptAfter saving the file, reload the shell configuration: $ . ~/.bashrc Now the lf command can be used anywhere with the same options as the script.
Conclusion
By studying and adapting this short shell program, readers improve their Bash scripting skills, learn how to build a practical file‑search tool, and see how to integrate it into their workflow via a custom alias.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
