Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

deleting zero byte files 1

Status
Not open for further replies.

icu812

MIS
Sep 10, 2001
52
US
Can someone please tell me how to delete zero byte files in a directory? Thanks
 
The obvious answer is

$ rm <filename>

but I think you must have tried that, you can also use the following -

$ find /my_path -size 0 -exec rm {} \;

Steve
 
I am wanting a scripot to automatically delete theses files.Guess I didn't mention that,sorry. Thanks for your help
 
Bung the find statement into a script and get cron to execute it on a regular basis. There's no point reinventing the wheel, unless you're Microsoft, of course! Cheers.
 
Or better still, just include the find statement as is in the crontab! Have a good weekend.
 
warning .... don't do that in roots crontab!
many many things can break if you do that command with the wrong starting path.

if you know that none of the zero byte files are needed for anything as a flag or a FIFO pipe then you could use something like
find . -level 0 -size 0 -type f -exec rm {} \;

(you might have to replace level with depth depending on which unix you are using)

hth
stan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top