find -print: Default Output and -ls
find -print writes the path of each match on its own line; it is the default action.
find prints matches by default, but the moment you add another action that default disappears, which is the source of many -prune surprises.
What it does
find -print outputs each matched path followed by a newline. If no action is given, -print is applied automatically. As soon as you add an action like -exec or -prune, the implicit -print is gone, so you must add it back explicitly where you want output. -ls prints ls -l style details.
Common usage
find . -name '*.log' -print
find . -name '*.log' -ls
find . -name node_modules -prune -o -type f -printOptions
| Action | What it does |
|---|---|
| Print the path plus a newline (the default) | |
| -print0 | Print the path plus a NUL byte |
| -ls | Print ls -l style details for each match |
| -printf FMT | GNU: print a custom format |
In CI
Remember that adding -prune (or any action) suppresses the automatic -print, so a prune expression that "outputs nothing useful" usually just needs an explicit -print on the action side. Pipe -print to wc -l to count matches.
Common errors in CI
No output from a working expression almost always means the implicit -print was canceled by another action; add -print back. -ls and -printf differ across implementations: -printf is GNU only, so on BSD/macOS find use -print with a downstream tool or -exec stat. Lines with spaces break naive parsing; prefer -print0.