0

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

I always used find; I don't recall using GNU find, but from one example I've seen I assumed the syntax of GNU find might be simpler (though might allow less operations).

I have two questions:

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

  2. Was GNU findintended to be simpler to find?

  • 4
    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 '18 at 11:07
  • 1
    Try find --version ;) – marcelm Oct 12 '18 at 12:56
  • 2
    Those systems you're referring to are GNU systems, GNU/Linux for most, though Debian is available for other a few other kernels as well. So it's not surprising that the find implementation on those systems is GNU find. – Stéphane Chazelas Apr 24 at 12:04
11

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 instead arguably more complex in order to be 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. GNU find's -delete will complain if you use it to delete a non-empty directory, but the corresponding option with e.g. OpenBSD's find will not (neither will delete the non-empty directory).

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.

  • 2
    And -print0, and -direxec, and -delete, and ... ;-). The null separator options available in GNU tools are particularly convenient. – Stephen Kitt Oct 12 '18 at 10:42
  • @StephenKitt But seldom needed :-) – Kusalananda Oct 12 '18 at 10:47
  • right, except when writing non-POSIX answers here ;-). (Or scripts which need to work anywhere.) – Stephen Kitt Oct 12 '18 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 '18 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 Oct 13 '18 at 12:19
2

What people often refer to as Linux is better referred to as GNU/Linux: Linux plus GNU. Therefore the tools you are using are probably GNU.

  • Linux: a kernel, it is used in GNU/Linux, Android, and many other systems.
  • GNU: an operating system, often used with the Linux kernel, but can also be used with BSD, Hurd, Cygwin (a DLL for Microsoft's Windows, it pretends to be a kernel), WSL (Windows Subsystem for Linux: GNU without Linux, on Microsoft's Windows), HPUX, Solaris, Dec Athena, and many others.

Therefore you are probably using GNU find.

GNU is a project to re-write, a Free (free as in freedom, not as in price) version of, all of Unix, including tools such as find, the GNU project does not worry about POSIX compliance: It will comply where it makes sense, but will also make improvements.

Also you assumption that there is only one other find is wrong.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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