Como faço para mover arquivos com base no tamanho?

0

Eu tentei isso:

find . -type f -size 128 -exec mv {} new_dir/  \;

O que não funcionou e não me deu um erro. Aqui está um exemplo de como é o arquivo ao usar stat -x

$ stat -x ./testfile | grep Size 
  Size: 128          FileType: Regular File
    
por DisplayName 15.09.2016 / 15:00

1 resposta

4

Da minha página de manual (em uma máquina MacOS 10.11)

 -size n[ckMGTP]
         True if the file's size, rounded up, in 512-byte blocks is n.  If
         n is followed by a c, then the primary is true if the file's size
         is n bytes (characters).  Similarly if n is followed by a scale
         indicator then the file's size is compared to n scaled as:

         k       kilobytes (1024 bytes)
         M       megabytes (1024 kilobytes)
         G       gigabytes (1024 megabytes)
         T       terabytes (1024 gigabytes)
         P       petabytes (1024 terabytes)

(sufixos diferentes de c sendo extensões não padrão).

Portanto, como você não especificou um sufixo, seu -size 128 significava 128 blocos , ou 64Kbytes correspondidos apenas para arquivos cujo tamanho estava entre 127 * 512 + 1 (65025 ) e 128 * 512 (65536) bytes.

Você deve usar -size 128c se desejar arquivos de exatamente 128 bytes, -size -128c para arquivos de tamanho estritamente menores que 128 bytes (0 a 127) e -size +128c para arquivos de tamanho estritamente maiores que 128 bytes ( 129 bytes e acima).

    
por 15.09.2016 / 15:04

Tags