PDA

View Full Version : Shell, clear temp folder



sekasi
May 29th, 2008, 02:18 PM
Heya guys.

Kinda need a shell script that can clear the content of a folder through cron.. Been messing a bit with it myself but it just wont clear it properly.

Wanna remove everything but the .htaccess file .. :/

If someone could point me in the right direction, I would be very grateful. Thanks.

sekasi
May 29th, 2008, 02:48 PM
Nm, sorted it. I forgot about xargs :D

Here's what it looks like if anyone should need one..



#!/bin/sh
searchdir=/absolute/path/to/your/directory/
find $searchdir \( -name \*\.tmp -o -name \*\.jpg \) -type f | xargs rm -f {}