Skip to main content
deleted 13 characters in body
Source Link
ilkkachu
  • 147.9k
  • 16
  • 268
  • 441

Depth 0 is the command line arguments, 1 the files contained within them, 2 the files contained within depth 1, etc.

-mindepth N tells to process only files that are at depth >= N or deeper, similar to how -maxdepth M tells to process only files are at depth <= M or lower. So if you want the files that are at depth 2, exactly, you need to use both.

Your command would match $RAW_DIR/foo/bam.bam, but not $RAW_DIR/bar.bam.

Try, e.g.

$ mkdir -p a/b/c/d
$ find ./a -maxdepth 2
./a
./a/b
./a/b/c
$ find ./a -mindepth 2
./a/b/c
./a/b/c/d
$ find ./a -maxdepth 2 -mindepth 2
./a/b/c

maxdepth with a negative argument doesn't mean anything:

$ find ./a -maxdepth -2
find: Expected a positive decimal integer argument to -maxdepth, but got ‘-2’

Depth 0 is the command line arguments, 1 the files contained within them, 2 the files contained within depth 1, etc.

-mindepth N tells to process only files that are at depth N or deeper, similar to how -maxdepth M tells to process only files are at depth M or lower. So if you want the files that are at depth 2, exactly, you need to use both.

Your command would match $RAW_DIR/foo/bam.bam, but not $RAW_DIR/bar.bam.

Try, e.g.

$ mkdir -p a/b/c/d
$ find ./a -maxdepth 2
./a
./a/b
./a/b/c
$ find ./a -mindepth 2
./a/b/c
./a/b/c/d
$ find ./a -maxdepth 2 -mindepth 2
./a/b/c

maxdepth with a negative argument doesn't mean anything:

$ find ./a -maxdepth -2
find: Expected a positive decimal integer argument to -maxdepth, but got ‘-2’

Depth 0 is the command line arguments, 1 the files contained within them, 2 the files contained within depth 1, etc.

-mindepth N tells to process only files that are at depth >= N, similar to how -maxdepth M tells to process only files are at depth <= M. So if you want the files that are at depth 2, exactly, you need to use both.

Your command would match $RAW_DIR/foo/bam.bam, but not $RAW_DIR/bar.bam.

Try, e.g.

$ mkdir -p a/b/c/d
$ find ./a -maxdepth 2
./a
./a/b
./a/b/c
$ find ./a -mindepth 2
./a/b/c
./a/b/c/d
$ find ./a -maxdepth 2 -mindepth 2
./a/b/c

maxdepth with a negative argument doesn't mean anything:

$ find ./a -maxdepth -2
find: Expected a positive decimal integer argument to -maxdepth, but got ‘-2’
Source Link
ilkkachu
  • 147.9k
  • 16
  • 268
  • 441

Depth 0 is the command line arguments, 1 the files contained within them, 2 the files contained within depth 1, etc.

-mindepth N tells to process only files that are at depth N or deeper, similar to how -maxdepth M tells to process only files are at depth M or lower. So if you want the files that are at depth 2, exactly, you need to use both.

Your command would match $RAW_DIR/foo/bam.bam, but not $RAW_DIR/bar.bam.

Try, e.g.

$ mkdir -p a/b/c/d
$ find ./a -maxdepth 2
./a
./a/b
./a/b/c
$ find ./a -mindepth 2
./a/b/c
./a/b/c/d
$ find ./a -maxdepth 2 -mindepth 2
./a/b/c

maxdepth with a negative argument doesn't mean anything:

$ find ./a -maxdepth -2
find: Expected a positive decimal integer argument to -maxdepth, but got ‘-2’