justasss
justasss

Reputation: 1

Copy all empty files into a folder with command line

I am trying to copy all empty files from the home directory into a folder that is on the desktop, using this:

find ~ -empty -exec cp {} /desktop/emptyfolder \;

However, I can't make it work.

Are there any other possible solutions to achieve this? Or maybe to write a bash script that could do this?

Upvotes: 0

Views: 469

Answers (1)

Raman Sailopal
Raman Sailopal

Reputation: 12877

Add -type f to the find command to force it to search for files and not directories and so:

find ~ -empty -type f -exec cp {} /desktop/emptyfolder \;

Upvotes: 1

Related Questions