OS-agnostic CLI tool written in Go for finding files or directories in a filesystem.
To build an executable that you can add to your PATH, run
go build -o locate
Or on windows:
go build -o locate.exe
After adding the binary to your PATH you should be able to use the locate command from anywhere.
Run locate -h for information about using locate.
If you want to search for a file in your working directory (including sub-directories), just run
locate file fileName
Flags:
-c,--case-sensitiveIf set to false, will ignore the case of file names. Default is false.-e,--exludeStrings to exlude when searching through file names.-h,--helphelp for file-p,--pathRoot directory to start searching at, defaults to your working directory-s,--strictIf set to false, will include file names that contain the name of the desired file. Default is false.
If you want to search for a folder in your working directory (including sub-directories), just run
locate dir dirName
Flags:
-c,--case-sensitiveIf set to false, will ignore the case of directory names. Default is false.-e,--exludeStrings to exlude when searching through directory names.-h,--helphelp for dir-p,--pathRoot directory to start searching at, defaults to your working directory-s,--strictIf set to false, will include directory names that contain the name of the desired directory. Default is false.
To search for a file called main.go (case sensitive and strict) starting at your working directory:
locate file main.go -c -s
To search for a directory called github (case sensitive) two directories up exluding directories that have a . in their name:
locate dir github -p ../../ -c -e .
Tip
If you want to exlude more than one string, use e twice! Like this: -e . -e a