5 ms·
Show HN: zfind – CLI like find but using SQL syntax and also does tar/zip
I wrote this because I needed to search a lot of files, including some archives, for files in a date range but couldn't find any good tools.
Also I never liked find's option syntax. I think most people already know SQL (or at least it's easier to learn) and a much better match for this task.
- berlinmonk 2y agoMaybe you should take a look at fselect, that uses SQL dialect for search queries and supports archives (and much more). https://github.com/jhspetersson/fselect https://github.com/jhspetersson/fselect
- conkeisterdoor 2y agoThis looks awesome, I'm gonna play with this today. Thanks for the rec
- laktak 2y agotbh, I probably wouldn't have written zfind if I had known about this. fselect still takes the SQL analogy a bit too far for my taste, still cool though :) Oh and fselect doesn't do tar.
- threecheese 2y agoAlso tbh, I strongly prefer your query strategy; it doesn’t require I remember an entire grammar, just a few keywords (‘size’ etc) which are probably at the top of your man page. If a replacement for ‘find’ - which annoys me because I have to dig through the man page anytime I do something nontrivial- forces me to dig through their man page to remember a grammar … you catch my drift. Hope you keep keepin on, and thanks.
- deleted 2y ago[deleted]
- mksybr 2y agoIf you're trying to replace find, please add something equivalent to find's -print0/-ls to feed it's output into xargs. Otherwise it may not work correctly on unusually named files (not that I've tried it yet). EDIT: seems to be a similar issue with fselect: https://github.com/jhspetersson/fselect/issues/150 https://github.com/jhspetersson/fselect/issues/150
- laktak 2y agoThanks, good point. I'll make sure to add it.
- neuthral 2y agogreat added this to my $PATH i make lots of custom bash file editing and this is gonna help mein the futuré
- mixmastamyk 2y agoNeat, at first glance the -w option is almost required… this often means it should be bare args, skipping the option syntax. Maybe relax the mandatory quotes too? zfind —-csv size gt 20k and name = foo
- pastage 2y agoThis reminds me how much I love tcpdump it is one of the best domain specific languages I have seen on the command line. Having "and port 53" do the right thing is beautiful also without quotes.
- luckman212 2y agoWhat's your favorite primer on tcpdump syntax? I don't know why, but I always have to go back to my notes for anything even mildly complex.
- laktak 2y agoThe bare args are for the path(s) to search. zfind -w 'size>20k and name="foo"' I could consider having the first arg reserved for -w zfind 'size>20k and name="foo"' but I much prefer the quotes and being allowed to write > instead of gt.
- mixmastamyk 2y agoThe path is rarely useful and almost always ".". Might want that as an option, "-p /etc" I used gt as bare word but doesn't preclude having escaped or quoted symbols as well, e.g.: size \> 20k 'size > 20k'
- baobun 2y ago> The path is rarely useful and almost always "." What, no. I will easily type out `find` invocations dozens/hundreds of time per workday over years and the fact that it requires the path as the first argument and won't accept it as last _still_ trips me up and is my one major gripe.
- laktak 2y agoalso does 7zip and rar now
- deleted 2y ago[deleted]