Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/selfup/filenamefinder
fuzzy find in go - exec or lib
https://github.com/selfup/filenamefinder
Last synced: about 1 month ago
JSON representation
fuzzy find in go - exec or lib
- Host: GitHub
- URL: https://github.com/selfup/filenamefinder
- Owner: selfup
- License: mit
- Created: 2021-04-04T19:23:18.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-03-12T05:52:00.000Z (almost 3 years ago)
- Last Synced: 2024-10-20T07:34:20.557Z (3 months ago)
- Language: Go
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# File Name Finder
Concurrent, recursive, file name finder.
Can search for multiple keywords in file names.
Output is pipe friendly, so you can grep or xargs all day.
### Install
```
go install github.com/selfup/filenamefinder@latest
```### Use
```
$ filenamefinder -h
Usage of filenamefinder:
-k string
keyword(s) for the filename - can be comma delimited
-p string
absolute path - can be comma delimited
```Example looking for all README files in $HOME and doing a count of matches (linux):
```
$ time filenamefinder -p="$HOME" -k='README' | wc -l
4815real 0m1.389s
user 0m4.960s
sys 0m2.708s
```---
Performance is quite similar to `find` but this is such little code I figured why not.
You can also use this in your go projects and not have to exec a shell command.
That's nice too.
### Use as a lib
```go
import (
"fmt"
"strings"filenamefinder "github.com/selfup/filenamefinder/pkg"
)scankeywords := strings.Split("first_keyword,second_keyword", ",")
scanPaths := strings.Split("/tmp,/etc,/home", ",")nfnf := filenamefinder.NewFileNameFinder(scanKeywords)
for _, path := range scanPaths {
nfnf.Scan(path)
}for _, file := range nfnf.Files {
fmt.Println(file)
}
```### Caveats
Currently fuzzy find which I prefer.
The rest can be narrowed down with grep or any other pipe freindly util.