Hacker News new | past | comments | ask | show | jobs | submit login

> It's not a beautiful tool, it's an over-large conglomeration of functionality that already exists in the shell

Find absolutely is a beautiful tool. It does one and only one thing: apply predicates to the file system.

> du -a . | grep filename

Except that's going to match on the dirname content as well, whereas `find -type f -name filename` will only match the actual file name.

And you're going to get complete junk in the first section of each line which you'll have to cleanup afterwards.

> (the awk is necessary to remove file sizes, you could combine du and awk in a shell function if desired)

Right, whereas if you use `find` it gives exactly what you want (or need)

> Why do you need both "-exec" and "-delete"?

You don't need both, but -delete provides additional clarity and forces depth-first traversal.

> Except that as I've shown above, it's already quite easy to execute a program for every file that matches some criteria

Except your examples are all broken since you're not using `basename`. Turns out it's not that easy, and it soon becomes complete shell-soup.

> and you don't have to learn the dozens of options used in find

They're not actually options, they're predicates.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: