Consider some common *nix systems (say Debian, Ubuntu, Fedora, CentOS, Arch and Kali).

I use Linux since 2014 but always used find. I don't recall personally using GNU find, but from one example I've seen I assumed the syntax of GNU find might be simpler (though might as well allow less operations).

Exceptionally, I have two questions:

  1. Is only find the default "find or-and operate" utility in common systems or these usually come with both find and GNU find?

  2. Was GNU findintended to be simpler than find?

  • 2
    you have always used GNU find on linux, unless you're a big user of find on busybox or android ;-) On non-linux systems, GNU find is usually named gfind. – mosvy Oct 12 at 11:07
  • Try find --version ;) – marcelm Oct 12 at 12:56
up vote 9 down vote accepted

GNU utilities often implement the POSIX standard, and then also extend it with extra functionality for added convenience (and, as the flip side of that, decreased portability across Unices). The portability aspect is why you sometime will see answers or comments on this site that are very careful to point out when a GNU utility or some other specific implementation of a utility is assumed.

If you are on a Linux system, you would very likely be using the GNU implementation of find, and you would probably not have another find installed. On non-Linux systems, you would have a native find and the possibility to also install GNU find (which would most often install under the name gfind or, less often, gnufind).

As with most GNU utilities, GNU find implements and extends the standard find specification. It is therefore not "simpler" but "more convenient", and it would be somewhat easier to do certain complex tasks with it than with a strictly standard compliant find.

Extended implementations of find often, for example, implement the -maxdepth and -mindepth predicates which the standard does not mention, and GNU find in particular also has -printf to print out the found pathnames using a variety of formatting possibilities (the standard find does not have -printf), and predicates for doing regular expression matching of various kinds on pathnames, as well as a number of other non-standard predicates, some of which are also found in other implementations of find (possibly with ever so slightly different semantics, like -execdir which works slightly different depending on what find is being used1).

The -delete predicate, used in the answer that you link to, is non-standard, but implemented by GNU find as well as in the find on some other non-Linux systems.

Most Linux systems, regardless of distribution, use the same coreutils and findutils toolset (variants like busybox exists, obviously). To use a completely different set of tool implementations, you would have to move to one of the open source BSD systems or to macOS, Solaris, AIX or some other commercial Unix.


1GNU find prepends ./ to pathnames when using -execdir while some other implementations don't.

  • And -print0, and -direxec, and -delete, and ... ;-). The null separator options available in GNU tools are particularly convenient. – Stephen Kitt Oct 12 at 10:42
  • @StephenKitt But seldom needed :-) – Kusalananda Oct 12 at 10:47
  • right, except when writing non-POSIX answers here ;-). (Or scripts which need to work anywhere.) – Stephen Kitt Oct 12 at 10:49
  • 1
    The main problem with the GNU documentation is that it tries to let people use non-standard aliases to POSIX methods and thus cause the related scripts to create a vendor lock in. – schily Oct 12 at 10:55
  • @StephenKitt -print0 is also available on *bsd and solaris; but on solaris xargs -0 doesn't work, so gxargs -0 (from /usr/bin/sfw) should be used instead. – mosvy 2 days ago

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.