---
name: "cdist-type__clean_path"
section: "7"
platform: "linux"
package: "cdist"
version: "7.0.0-5"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/cdist-type__clean_path"
---

# cdist-type\_\_clean\_path(7)

Remove files and directories which match the pattern.

## NAME

cdist-type\_\_clean\_path - Remove files and directories which match the pattern.

## DESCRIPTION

Remove files and directories which match the pattern.

Provided path must be a directory.

Patterns are passed to **find**'s **-regex** - see **[find(1)](/find/1.md)** for more details.

Look up of files and directories is non-recursive (**-maxdepth 1**).

Parent directory is excluded (**-mindepth 1**).

This type is not POSIX compatible (sorry, Solaris users).

## REQUIRED PARAMETERS

- **pattern**

  Pattern of files which are removed from path.

## OPTIONAL PARAMETERS

- **path**

  Path which will be cleaned. Defaults to **$\_\_object\_id**.

- **exclude**

  Pattern of files which are excluded from removal.

- **onchange**

  The code to run if files or directories were removed.

## EXAMPLES

```
__clean_path /etc/apache2/conf-enabled \
    --pattern '.+' \
    --exclude '.+\(charset\.conf\|security\.conf\)' \
    --onchange 'service apache2 restart'
__clean_path apache2-conf-enabled \
    --path /etc/apache2/conf-enabled \
    --pattern '.+' \
    --exclude '.+\(charset\.conf\|security\.conf\)' \
    --onchange 'service apache2 restart'
```

## AUTHORS

Ander Punnar \<ander-at-kvlt-dot-ee\>

## COPYING

Copyright (C) 2019 Ander Punnar. You can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

## COPYRIGHT

ungleich GmbH 2021
