LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Delete Empty files (https://www.linuxquestions.org/questions/linux-newbie-8/delete-empty-files-73667/)

whospeaks2me 07-17-2003 05:10 PM

Delete Empty files
 
:) hello everyone!!

how do i create a shell script that will delete any empty, regular files from the home directory. The script should not delete hidden files (even if they are empty).

thanks 100 times

Tinkster 07-17-2003 06:05 PM

Code:

#!/bin/bash
cd ~
find -type f -size 0b -iname "*" ! -iname ".*" -exec rm {} \;

If you don't trust me (and you shouldn't ;} trust
anyone, always test stuff) run it without the exec
bit, first, to make sure it only finds files you
REALLY want deleted....

Cheers,
Tink

P.S.: find rocks ;}

Tinkster 07-18-2003 10:39 PM

And, did it work? :)

Cheers,
Tink


All times are GMT -5. The time now is 03:11 AM.