# find: -maxdepth, -type f and -size +1c narrow the result

Published: 2026-11-30

Rights: original
Source: https://kairos-2z6s.onrender.com/res/find-options-full-en
find can limit depth, filter by type and filter by size. The run shows -maxdepth 1, -type f and -size +1c over three files.

Each command below is the exact command that was run and each output block is copied from the recorded log. Test ids, log hashes and exit statuses are in the evidence table.

(Test: 3 tests were run, TE-31-A, TE-31-B and TE-31-C. The expected non-zero exit is TE-31-C (exit status 1). Every row has a recorded log in the evidence archive. The evidence table lists the exit status and log hash of every row, and no Exit status line on this page is for the A row.)

### TE-31-A: find options compose: -maxdepth, -type and -size narrow the result

Setup for this run, inside a throwaway directory (`mktemp -d`):

```bash
mkdir -p d/sub; printf '12345\n' > d/big.txt; printf '1' > d/small.txt; printf 'x\n' > d/sub/deep.txt
```

Command:

```bash
echo all=$(find d -type f | wc -l); echo depth1=$(find d -maxdepth 1 -type f | wc -l); echo size=$(find d -type f -size +1c | wc -l)
```

Recorded output:

```
all=3
depth1=2
size=2
```

### TE-31-B: -maxdepth 1, -type f and -size +1c together keep only the big file in the top folder

Setup for this run, inside a throwaway directory (`mktemp -d`):

```bash
mkdir -p d/sub; printf '12345\n' > d/big.txt; printf '1' > d/small.txt; printf 'x\n' > d/sub/deep.txt
```

Command:

```bash
find d -maxdepth 1 -type f -size +1c
```

Recorded output:

```
d/big.txt
```

Exit status: 0. This status and the output match what was written before the run.

### TE-31-C: expected non-zero exit: a negative -maxdepth value is rejected

Setup for this run, inside a throwaway directory (`mktemp -d`):

```bash
mkdir -p d
```

Command:

```bash
find d -maxdepth -1
```

Recorded output: none, standard output was empty.

Standard error from the same run:

```
find: Expected a positive decimal integer argument to -maxdepth, but got ‘-1’
```

Exit status: 1. This status matches what was written before the run. The expected error wording was corrected after the first run, because find words its -maxdepth error differently than the first prediction. The wording of this find error is specific to GNU find 4.8.0.

TE-31-B: by the setup, d/big.txt has 6 bytes, d/small.txt has 1 byte and d/sub/deep.txt has 2 bytes. With -maxdepth 1, -type f and -size +1c, only d/big.txt was printed. TE-31-C: find d -maxdepth -1 exited with status 1 and printed find: Expected a positive decimal integer argument to -maxdepth, but got ‘-1’ to standard error.

## Limits

Other size units, other type values and actions such as -exec are not tested here. Not tested on this page: the positional options `-daystart`, `-follow` and `-regextype`, the options `-depth`, `-mindepth`, `-mount`, `-noleaf` and `-xdev`, the tests `-name`, `-iname`, `-path`, `-regex`, `-empty`, `-newer`, `-mtime`, `-perm`, `-user` and `-group`, the actions `-delete`, `-print0`, `-printf`, `-prune`, `-quit` and `-ls`, and the operators `-o`, `-not` and parentheses. The names come from `find --help` in GNU findutils 4.8.0, which lists them under those headings. No run here used them.

## Source

- https://www.gnu.org/software/findutils/manual/

## Evidence

- `TE-31-A`: find options compose: -maxdepth, -type and -size narrow the result

- logs: one recorded log for each row above
- Recorded on: Linux x86_64, kernel 7.3.4; bash 5.1.16; git 2.34.1; python 3.10.12; findutils 4.8.0; grep 3.7; sed 4.8; gawk 5.1.0; tar 1.34; curl 7.81.0. Locale C.UTF-8, TZ=UTC.

## Evidence table

| Test | What it checks | Exit | Verdict | Log sha256 (first 12) |
|---|---|---|---|---|
| `TE-31-A` | find options compose: -maxdepth, -type and -size narrow the result | 0 | PASS | `86ed3ad51c9d` |
| `TE-31-B` | -maxdepth 1, -type f and -size +1c together keep only the big file in the top folder | 0 | PASS | `69a6f07b04c1` |
| `TE-31-C` | expected non-zero exit: a negative -maxdepth value is rejected | 1 | PASS | `0f7b7ec1e517` |

Every row has a recorded log holding the setup commands, the command, stdout, stderr, exit status and the final directory state. The first 12 characters of the log's sha256 are in the table.

## Related guides
- [Bash variables, loops and if: the basics](https://kairos-2z6s.onrender.com/res/bash-variables-loops-full-en)
- [Pipes and redirection: where command output goes](https://kairos-2z6s.onrender.com/res/pipes-redirection-full-en)
- [find: list files by name and sort the result](https://kairos-2z6s.onrender.com/res/find-basics-full-en)
- [How to fix a Git merge conflict step by step](https://kairos-2z6s.onrender.com/res/fix-git-merge-conflict-en)
- [git bisect: find the commit that broke something](https://kairos-2z6s.onrender.com/res/git-bisect-full-en)
- [mkdir, cp, mv and rm: the basic file commands](https://kairos-2z6s.onrender.com/res/file-commands-full-en)
- [sed basics: replace text in a stream](https://kairos-2z6s.onrender.com/res/sed-basics-full-en)
