Skip to content

Instantly share code, notes, and snippets.

@jwieder
Created February 24, 2016 17:25
Show Gist options
  • Save jwieder/dd914ce765a3fb378ab7 to your computer and use it in GitHub Desktop.
Save jwieder/dd914ce765a3fb378ab7 to your computer and use it in GitHub Desktop.
Finds files of a given extension in a directory and moves them into another directory. Combine with cron to - for example - move log files to a network share for long term storage. Follows symlinks. Adjust maxdepth to increase or decrease recursion. Simple & effective!
#!/bin/bash
Source="/var/log"
Destination="/to/your/backups"
find -L $Source -maxdepth 3 -type f -name "*.gz" -exec mv {} $Destination \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment