Who else hates the find command? I sure do sometimes

It’s great - it’s really powerful, but it’s also a monumental PITA to use at times…

Hate is such a strong word, it’s probably more a case of “Love / Hate”…

Take something as simple as figuring out which folder in “/” is eating all your storage :

(probably as root - e.g. via sudo)

find / -mount -xdev -maxdepth 1 -type d -exec du -sh {} \; | sort -h

(should “allegedly” find folders ONLY on the current fileysystem, one level deep and report their usage “summary” in human readable form and sort on human readable form)

But it DOESN’T work - I used BOTH “-mount” and “-xdev” so it doesn’t cross filesystems - BUT IT STILL DOES ANYWAY!

And of course we don’t give a rat’s (contraction of “rat’s arse”) about /proc, or /sys - but to exclude those - we have to end up with a chain of “prune” arguments, one for EVERY directory you want to exclude :

find . -mount -maxdepth 1 -path /sys -prune -o -path /proc -prune -o -type d -exec du -sh {} \; | sort -h

That’s so inelegant…

And - even that doesn’t work (Ubuntu 18.04 server) :

root@REDACTED:/# find . -mount -maxdepth 1 -path /sys -prune -o -path /proc -prune -o -type d -exec du -sh {} \; | sort -h
du: cannot access ‘./proc/12109/task/12109/fd/3’: No such file or directory
du: cannot access ‘./proc/12109/task/12109/fdinfo/3’: No such file or directory
du: cannot access ‘./proc/12109/fd/4’: No such file or directory
du: cannot access ‘./proc/12109/fdinfo/4’: No such file or directory

6.1G ./var
8.1G ./home
13G ./usr
39G ./datahub
75G .

See? The F–KING thing is still traversing /proc!!! And even worse? /datahub is an NFS mount from a NAS device - so it’s F–KING ignoring my “-mount” argument (same result using -xdev, or BOTH -mount and -xdev). Note also - same result with either “find .” or “find /” (while $PWD = / ). And that total of 75 G INCLUDES the 39 G from NFS mounted NAS share /datahub…

And it’s even worse… e.g. find in Solaris doesn’t even support case insenstive search, so :

find / -name STRINGstring -print

Won’t return something matching stringSTRING!!!

And having to have multiple escapes for wildcards e.g.

find / -name \*STRING\*string\*

It’s so ugly… So in Solaris - you’d probably have to have a loop to cycle through every possible upper and lowercase variation of that string…

I should probably write a script that does something like the old “hog.exe” (or hog.com) MS-DOS free/shareware utility did - but - how to deploy everywhere I need it? And ensure it works on Linux distros from Debian 4 (yeah some customers STILL running stuff that was already EOL 10+ years ago!) through to RHEL 8 - AND - Solaris 10 and 11!!!

sorta resolved my own pet peeve…

Apparently I can :

find . -mount -maxdepth 1 -fstype ext4 -path /sys -prune -o -path /proc -prune -o -type d -exec du -sh {} \; | sort -h

(it still annoying checks in /proc even though I told it not to, but its closer to what I want)

I hate find and other similar commands like the version mix-up of tar. Well, at least I can remember tar commands, but I usually have to look up find arguments over and over again, because I can’t remember them due to their clunkiness.

The reason such tools are crap is because they are pulling off a Windows. Windows is famous for extreme and utter backward compatability. For example, you may still use the F keys beyond F12, on Windows.

The find command is also one such remnant of the past, that, to be honest, makes my life harder, instead of easier, because it’s easy to do something wrong with it and the syntax is extremely backward compatible, which also means, it’s not too forward compatible, if you see it in context with other modern tools.

The last time I wanted to use find just to quickly check if it works, as it should, it also took way too long, to finish searching, so I wouldn’t even know if it works, as I wanted it to. Wasting time, once again.

I had enough of that shit, so I searched for an alternative and immediately found a good one:

It’s not only easier to use, modern and written in Rust (yes, that’s a plus on its own), but it’s also, what feels like, by a million times faster than the original find command.

In fact, it finished the earlier search so quickly, I was doubting if it works correctly. I ran the search a couple of times in a row and it actually worked, as it should and I could go on with the thing, I actually wanted to do with these results, i.e. this tool saved my time instead of stealing it, like find did.

# Installation
sudo apt install -y fd-find
# Usage
touch test.test
fdfind -e '.test'
rm test.test