Size: 300
Comment: Delete files not modified in n days
|
Size: 876
Comment: Faster version of mtime-based file removal
|
Deletions are marked like this. | Additions are marked like this. |
Line 9: | Line 9: |
find /path/to/files* -mtime +30 -exec rm {} \; | find . -type f -mtime +30 -exec rm {} \; # Same, but faster find . -type f -mtime +30 -print0 | xargs -0 -n256 rm }}} === Replace text in all files in & under the current directory === {{{#!highlight sh numbers=off find . -type f -exec sed -i 's/old/new/g' {} \; }}} === Find files NOT named something === {{{#!highlight sh numbers=off # Find files matching a pattern that are NOT already compressed, then compress them # (This particular example compresses Maildirs for use w/ dovecot's transparent decompression) find . -type f -name '*S=*' -not -name '*.gz' -print0 | xargs -0 -P4 -n 16 zopfli -l100 |
Contents
Delete files not modified in n days
Useful for clearing out caches that aren't properly cleaned out otherwise.
# Delete files not modified in 30 days
find . -type f -mtime +30 -exec rm {} \;
# Same, but faster
find . -type f -mtime +30 -print0 | xargs -0 -n256 rm
Replace text in all files in & under the current directory
find . -type f -exec sed -i 's/old/new/g' {} \;
Find files NOT named something
# Find files matching a pattern that are NOT already compressed, then compress them
# (This particular example compresses Maildirs for use w/ dovecot's transparent decompression)
find . -type f -name '*S=*' -not -name '*.gz' -print0 | xargs -0 -P4 -n 16 zopfli -l100