I'm trying to get a file's size.
Specifically, I want to check whether a file is larger than 650MB.
I've tried:
find . -name "filename" -size +681574400 -print
Oddly, that didn't seem to work.
(NB: 1024 bytes x 1024 x 650 = 681574400 bytes = 650 MB)
The problem seems to be the "-size" primary and it's numerical argument "+681574400".
The man pages say:
Quote:
All primaries which take a numeric argument allow the number to be pre-
ceded by a plus sign (``+'') or a minus sign (``-''). A preceding plus
sign means ``more than n'', a preceding minus sign means ``less than n''
and neither means ``exactly n''.
So I don't understand why it doesn't work.
I have since found that the problem can also be solved by getting the file size with ls -l and awk, but I think that's to AWKward (horrible pun
.
Seriously, I've got these questions:
- Why does the above not work and what needs to be done for it to work?
- What do people think is the best and safest way of doing such a file size check in a script?
NB: the shabang is #!/bin/sh -- I could obviously change that to anther shell/language, but I want to remain as compatible as possible.
Many thanks in advance!