CDIST-TYPE__CLEAN_PATH(7)

πŸ’– cdist-type__clean_path β€” the manual page, but make it make sense πŸ’–

okay bestie, welcome to cdist-type__clean_path(7) β€” yes that's the whole manual name, it's giving very ✨ official ✨. this is the type you call when a directory has collected stray files like a group chat collects unread messages and you just need them gone. 🧹✨


🌸 NAME 🌸

cdist-type__clean_path β€” remove files and directories which match the pattern.


✨ DESCRIPTION ✨

so basically: remove files and directories which match the pattern. that's the whole vibe. πŸ’…

a few things you absolutely need to know before you start deleting stuff, no cap:

  • the provided path must be a directory. like, fr, it has to be a dir.
  • patterns get passed straight to find's -regex β€” go read find(1) for the deets, iykyk.
  • the lookup of files and directories is non-recursive (-maxdepth 1), so it only looks at the top level, not the whole tree.
  • the parent directory is excluded (-mindepth 1), so you're not nuking the dir itself. 🫢
  • this type is not POSIX compatible β€” sorry, Solaris users 😭 (genuinely sorry tho).

πŸ‘‘ REQUIRED PARAMETERS πŸ‘‘

  • pattern β€” pattern of files which are removed from path. mandatory, babes. no pattern, no cleanup.

πŸŽ€ OPTIONAL PARAMETERS πŸŽ€

  • path β€” path which will be cleaned. defaults to $__object_id, so if you don't say anything it just uses that. iconic default behaviour honestly.
  • exclude β€” pattern of files which are excluded from removal. the VIP list. the ones who get to stay. πŸ¦‹
  • onchange β€” the code to run if files or directories were removed. like, if something actually got deleted, then do this thing. main character energy. πŸ”₯

🌈 EXAMPLES 🌈

here's the glow-up in action β€” first one uses the path directly, second one uses an object id and passes --path explicitly. both slay:

__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'

see how --exclude keeps charset.conf and security.conf safe while everything else in that dir gets yeeted and apache gets restarted? that's the whole trick. ⭐

careful bestie β€” --pattern '.+' matches basically everything, so double-check your --exclude before you run this on anything that matters. πŸ’€

πŸ’œ 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.


ungleich GmbH 2021


and that's the whole page, bestie. πŸ’– this was cdist-type__clean_path, manual version 7.0.0, dated Jul 31, 2022, brought to you by cdist itself. go forth and clean those paths responsibly. mwah. πŸ’…βœ¨

πŸ“¦ where this page comes from