Findutils 4.4.x on Ubuntu does not allow me to specify the `depth` option

Mission: A list of all direct permutations of the directory, which is the folder itself.

In BSD (Mac OS) it works find . -type d -depth 1.

This is the output of Ubuntu 12.04 (GNU findutils 4.4.2):

$ find . -type d -depth 1
find: warning: you have specified the -depth option after a non-option argument -type,
but options are not positional (-depth affects tests specified before it as well as 
those specified after it).  Please specify options before other arguments.

find: paths must precede expression: 1
Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]

Ok, the following attempt:

$ find . -depth 1 -type d
find: paths must precede expression: 1
Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]

Germ, well, maybe he wants ...

$ find -depth 1 . -type d
find: paths must precede expression: 1
Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]

Apparently not, wtf, if necessary ...

$ find . -depth=1 -type d
find: unknown predicate `-depth=1'

No, that was obvious. So let's try as a last resort ...

$ find . -mindepth 1 -maxdepth 1 -type d
<my directories>

I, success! But, erm, why ...?

And as a bonus question, why is it -mindepth 1 -maxdepth 1much faster than -depth 1on BSD / OSX?

+3
source share
2 answers

The parameter -depthdoes not accept an argument:

-depth Process each directory contents before the directory itself.

, -name, -type, -, -depth. .

+2

find -depth :

  • -depth (.. ). , , , . , find .

  • -depth n n (.. , ). -depth, , . , find (OS X, GNU findutils, -, ).

-find n , , , . , , -mindepth n -maxdepth n.

+3

All Articles