[NTLUG:Discuss] find: 1G < 1024M?
Wayne Walker
wwalker at solid-constructs.com
Tue Oct 19 17:57:04 CDT 2010
On Tue, Oct 19, 2010 at 01:57:19PM -0500, Stuart Johnston wrote:
> I have this command to find files smaller than a particular size:
>
> find ./ -regex ".*\.[mn][pu][gv]" -size -1G -type f -exec ls -lh {}
> \; | awk '{ print $8 ": " $5 }'
>
> This prints nothing. If I change it to use -1024M, it gives the
> expected output:
>
> find ./ -regex ".*\.[mn][pu][gv]" -size -1024M -type f -exec ls -lh
> {} \; | awk '{ print $8 ": " $5 }'
> ./1211_20100930175900.nuv: 736M
> ./1211_20100927175900.nuv: 741M
> ./1211_20100922175900.nuv: 736M
>
>
> Any ideas why -1G is not working the way I'm expecting?
My _guess_ is granularity. -1G means "less than 1G". somehow that
means 0G which is 0 bytes.
[wwalker at speedy ~] [] $ cd /dev/shm
[wwalker at speedy shm] [] $ mkdir foo
[wwalker at speedy shm] [] $ cd foo
[wwalker at speedy shm] [] $ dd if=/dev/zero bs=1048576 of=1m count=1
1+0 records in
1+0 records out
1048576 bytes (1.0 MB) copied, 0.00148686 s, 705 MB/s
[wwalker at speedy shm] [] $ dd if=/dev/zero bs=1048576 of=100m count=100
100+0 records in
100+0 records out
104857600 bytes (105 MB) copied, 0.0966602 s, 1.1 GB/s
[wwalker at speedy shm] [] $ dd if=/dev/zero bs=1048576 of=1023m count=1023
1023+0 records in
1023+0 records out
1072693248 bytes (1.1 GB) copied, 1.16221 s, 923 MB/s
[wwalker at speedy shm] [] $ dd if=/dev/zero bs=1048576 of=1025m count=1025
1025+0 records in
1025+0 records out
1074790400 bytes (1.1 GB) copied, 4.33152 s, 248 MB/s
[wwalker at speedy foo] [] $ find . -size -1024M
.
./1m
./1023m
./100m
[wwalker at speedy foo] [] $ find . -size -1G
[wwalker at speedy foo] [] $ touch 0b
[wwalker at speedy foo] [] $ find . -size -1G
./0b
[wwalker at speedy foo] [] $ ls -l
total 2204904
-rw-rw-r-- 1 wwalker wwalker 0 Oct 19 17:54 0b
-rw-rw-r-- 1 wwalker wwalker 104857600 Oct 19 17:52 100m
-rw-rw-r-- 1 wwalker wwalker 1072693248 Oct 19 17:53 1023m
-rw-rw-r-- 1 wwalker wwalker 1074790400 Oct 19 17:53 1025m
-rw-rw-r-- 1 wwalker wwalker 1048576 Oct 19 17:52 1m
[wwalker at speedy foo] [] $ find . -size -1024M
.
./0b
./1m
./1023m
./100m
[wwalker at speedy foo] [] $ find . -size -1G
./0b
--
Wayne Walker
wwalker at solid-constructs.com
(512) 633-8076
Senior Consultant
Solid Constructs, LLC
More information about the Discuss
mailing list