-1

While working in a UNIX environment via SSH today, my cohort stumbled on a seeming idiosyncrasy in the GNU findutils related to the -size flag.

When I run the ls -l command, it tells me a file is 155 bytes in size. But running find ~/ -size -1K returns no results. It only matches the file for exactly 1k.

Futhermore, I know it's not using the du result to find files because du returns 4k for the same file. What gives? It seems like memory is provided in 4k "chunks" if du is to be trusts, and that ls -l finds the "true" size of a file, but find produces radically different results than expected. Any help would be appreciated, and I am certain this has come up for others in the past, but I cannot for the life of me find a result anywhere.

Thanks!

  • 1
    `-1k` means "less than one block of size 1024 bytes", which `find` understands as "zero blocks of size 1024 bytes", i.e. 0 bytes. `find` seems to use integers for block counting. You probably want `-size -1024c`. – Roman Jun 01 '16 at 14:49
  • 1
    And this question is really for [unix.se]. – Roman Jun 01 '16 at 14:53

1 Answers1

0

According to this manual page capital K suffix on sizes is not supported. Use lower-case k for kilobytes. You probably got 1 which is equivalent to 1b, i.e. one 512-byte block. That should include a 155-byte file of course, so it's a bit confusing.

unwind
  • 391,730
  • 64
  • 469
  • 606