# Shell, clear temp folder

**URL:** <https://forum.kirupa.com/t/shell-clear-temp-folder/261666>\
**Category:** programming\
**Created:** [May 29, 2008, 5:18pm UTC](https://forum.kirupa.com/t/shell-clear-temp-folder/261666 "2008-05-29T17:18:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sekasi](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@sekasi](https://forum.kirupa.com/u/sekasi)\
**Post date:** [May 29, 2008, 5:18pm UTC](https://forum.kirupa.com/t/shell-clear-temp-folder/261666/1 "2008-05-29T17:18:54Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![sekasi](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@sekasi](https://forum.kirupa.com/u/sekasi)\
**Post date:** [May 29, 2008, 5:48pm UTC](https://forum.kirupa.com/t/shell-clear-temp-folder/261666/2 "2008-05-29T17:48:00Z")

</div>

Nm, sorted it. I forgot about xargs 😃

Here’s what it looks like if anyone should need one…

```auto

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

```
