Skip to content

Instantly share code, notes, and snippets.

@darth-veitcher
Created October 27, 2017 08:00
Show Gist options
  • Save darth-veitcher/95ab4eee60b7b5868b6ea63df8a6710d to your computer and use it in GitHub Desktop.
Save darth-veitcher/95ab4eee60b7b5868b6ea63df8a6710d to your computer and use it in GitHub Desktop.
useful linux filesystem commands
# Archive content which hasn't been modified within the last 6months
find . -mtime +180 | while read -r name; do rsync -rLvPz --remove-source-files "$name" rsync://homenas/Backups/hd/; done

# Delete folders which have contents < 50kb
find /path/to/root/folder -mindepth 1 -maxdepth 1 -type d -exec du -ks {} + | awk '$1 <= 50' | cut -f 2- | xargs -d \\n rm -rf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment