A sane replacement for command line file search
I tend to use the UNIX command line A LOT. I find it very comfortable to work when I am developing and follow the “Unix as IDE” way. The command line is really rich, and you could probably learn a new different command or parameter each day and still be surprised every day for the rest of your life. But there are some things that sticks and gets done, probably not on the most efficient way.
In my case, is using the command `find` to search for files. 95% of the times I use it, is in this form:
find . -name '*some_text*'
Which means ‘find in this directory and all the subdirectories a file that contains some_text in its filename’
It’s not that bad, but I also use a lot ack, which I think is absolutely awesome. I think is a must know for anyone using Unix command line. It is a replacement for grep as a tool for searching code, and works the following way (again, in my 90% usage)
Which means ‘search in all the files that look like code under this directory and subdirectories that contains the text some_text‘ (some_text can be a regex, but usually you can ignore that part)
So, after a couple of tests, I decided to make myself my own ack-inspired find replacement, and called it ffind. I’ve been using it for the last couple of days, and it integrates quite well on my workflow (maybe surprisingly, as I’ve done it with that in mind)
Basically it does this
Which means ‘find in this directory and all the subdirectories a file that contains some_text in its filename’ (some_text can be a regex). It has also a couple of interesting characteristics like it will ignore hidden directories (starting with a dot), but not hidden files, it will skip directories that the user is not allowed to read due permissions and the output will have by default the matching text in color.
The other use case is
ffind /dir some_text
Which means ‘find in the directory ‘/dir’ and all the subdirectories a file that contains some_text in its filename’
There are a couple more params, but they are there to deal with special cases.
It is done in Python, and it is available in GitHub. So, if any of this sounds interesting, go there and feel free to use it! Or change it! Or make suggestions!