| 
  
   Size: 807 
  
  Comment:  
 | 
  
   Size: 1675 
  
  Comment:  
 | 
| Deletions are marked like this. | Additions are marked like this. | 
| Line 9: | Line 9: | 
| find /path/to/files* -mtime +30 -exec rm {} \; | find /tmp -type f -mtime +30 -exec rm {} \; # Same, but faster find /tmp -type f -mtime +30 -print0 | xargs -0 -n256 rm  | 
| Line 24: | Line 26: | 
| # Version that uses pigz find . -type f -name '*S=*' -not -name '*.gz' -print0 | xargs -0 -n 16 pigz -11 -I100 }}} === Fix whitespace issues === {{{#!highlight sh numbers=off for EXTENSION in php css html js txt md; do # Remove whitespace (incl. tabs) at the end of lines find . -type f -name "*${EXTENSION}" -exec sed -i "s/[[:blank:]]*$//" {} \; # Add trailing newlines to the end of a file find . -type f -name "*${EXTENSION}" -exec sed -i -e '$a\' {} \; # Replace tabs w/ spaces find . -type f -name "*${EXTENSION}" -exec sed -i 's/\t/ /g' {} \; # UNIX newlines find . -type f -name "*${EXTENSION}" -exec dos2unix {} \; done }}} === Delete all dangling symbolic links === {{{#!highlight sh # Compatible w/ GNU find only find -xtype l -delete  | 
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 /tmp -type f -mtime +30 -exec rm {} \;
# Same, but faster
find /tmp -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
# Version that uses pigz
find . -type f -name '*S=*' -not -name '*.gz' -print0 | xargs -0 -n 16 pigz -11 -I100
Fix whitespace issues
for EXTENSION in php css html js txt md; do
  # Remove whitespace (incl. tabs) at the end of lines
  find . -type f -name "*${EXTENSION}" -exec sed -i "s/[[:blank:]]*$//" {} \;
  # Add trailing newlines to the end of a file
  find . -type f -name "*${EXTENSION}" -exec sed -i -e '$a\' {} \;
  # Replace tabs w/ spaces
  find . -type f -name "*${EXTENSION}" -exec sed -i 's/\t/    /g' {} \;
  # UNIX newlines
  find . -type f -name "*${EXTENSION}" -exec dos2unix {} \;
done