Find regular files under /var/tmp larger than 100 MiB.
Which GNU find condition is appropriate?
find -size +100M selects files whose measured size is greater than 100 MiB in GNU find's M unit.
Detailed explanation
find /var/tmp -type f -size +100MCorrect. -size +100M selects files larger than 100 MiB.
Correct. -size +100M selects files larger than 100 MiB.
find /var/tmp -type f -size 100MIncorrect. Without a sign, the size test is an exact unit count rather than greater-than.
Incorrect. Without a sign, the size test is an exact unit count rather than greater-than.
find /var/tmp -type f -size -100MIncorrect. -100M selects files smaller than the threshold.
Incorrect. -100M selects files smaller than the threshold.
find /var/tmp -type f -mtime +100Incorrect. -mtime tests age in days, not file size.
Incorrect. -mtime tests age in days, not file size.
Try it yourself
An example you can run in a temporary verification environment.
tmp=$(mktemp -d); truncate -s 101M "$tmp/large"; truncate -s 50M "$tmp/small"; find "$tmp" -type f -size +100M -printf '%f\n'; rm -rf "$tmp"Expected result
largeKey points
- + means greater than
- M is MiB in GNU find
- -mtime is a time condition
Notes
- Environment: GNU findutils 4.x / sparse一時ファイル
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.