Find regular *.conf files under current and pass as many results as possible together to chmod g-w.
Which command is appropriate?
find -exec command {} + appends multiple matching paths to each command invocation. Using \; normally runs one invocation per result.
Detailed explanation
find current -type f -name '*.conf' -exec chmod g-wIncorrect. The -exec expression is incomplete without a terminator.
find current -type f -name '*.conf' -exec chmod g-w {} \;Incorrect. \; terminates -exec but usually invokes chmod once per file.
find current -type f -name '*.conf' -exec {} chmod g-w +Incorrect. The command and placeholder are in the wrong order.
find current -type f -name '*.conf' -exec chmod g-w {} +Correct. -exec chmod g-w {} + batches matching paths.
Try it yourself
An example you can run in a temporary verification environment.
tmp=$(mktemp -d); touch "$tmp/a.conf" "$tmp/b.conf"; chmod 660 "$tmp/a.conf" "$tmp/b.conf"; find "$tmp" -type f -name '*.conf' -exec chmod g-w {} +; stat -c '%a' "$tmp/a.conf" "$tmp/b.conf"; rm -rf "$tmp"Expected result
640
640Key points
- {} is replaced by results
- + batches results
- \; runs one at a time
Notes
- Environment: GNU findutils 4.x / GNU chmod / 一時ファイル
- Use disposable files and directories for destructive or timestamp-related checks.
- Command details can vary slightly between GNU and non-GNU implementations.
Foundation review
Place the operation
Both terminators are valid, but the plus form reduces process launches by batching arguments.
Check the side effect
Use harmless commands and temporary files when observing invocation grouping.