Moving files of a certain size in Ubuntu using a terminal

I want to move all files in a specific folder of size 0 bytes. I know that the following prints all files the size of zero bytes.

find /home/Desktop/ -size  0

But I want to move them to another folder, so I tried:

find /home/Desktop/ -size  0 | xargs -0 mv /home/Desktop/a

But this does not work.? Is there any other way to do this? What am I doing wrong?

+4
source share
2 answers

You can do this using the function -exec:

find /home/Desktop/ -size 0 -exec mv '{}' /home/Desktop/a \;
+2
source

find default , . -print0 , . -0 of xargs , .

find /home/Desktop/ -size 0 -print0 | xargs -0 -I {} mv {} /home/Desktop/a

find -exec

find -type f, -maxdepth 1, , descend. , !

+1

Source: https://habr.com/ru/post/1524831/


All Articles