$
Apprendre Manuel Linux
fr
XP :0
Quête 85DeepSearcher
+210 XP

Advanced find by Size, Time & Exec (-size, -mtime, -exec)

Lancer le terminal interactif pour cette quête→Aucune installation requise • S'exécute dans le navigateur

Concept et aperçu

Beyond basic filename queries, find is a powerhouse filter engine for automated system cleanup and log rotation:

- -size +50M: Filters for files strictly larger than 50 Megabytes (+ for greater than, - for less than).
- -mtime -7: Filters for files modified within the last 7 days.
- -exec {} +: Passes all matched files directly into a command in batches, replacing {} with matched file paths.

Combining these allows single-line system maintenance, such as finding and purging runaway logs: find /var/log -size +50M -exec rm {} +.

Find large log files modified recently using find /var/log -size +50M -mtime -7, then delete the oversized crash dump using find /var/log -size +50M -exec rm {} +.

Référence de syntaxe des commandes

Command / SyntaxDescription
find /var/log -size +50M -mtime -7Find files larger than 50MB modified within 7 days
find /var/log -size +50M -exec rm {} +Find and automatically remove files larger than 50MB

Objectifs de vérification

  • ○
    Filter files by size and modification time with find
  • ○
    Delete oversized log using find -exec rm

Prêt à terminer la Quête 85?