Skip to content

Instantly share code, notes, and snippets.

@georghildebrand
Created November 14, 2019 16:09
Show Gist options
  • Save georghildebrand/01e93cc36b1dc36d1014b9e0bd490df2 to your computer and use it in GitHub Desktop.
Save georghildebrand/01e93cc36b1dc36d1014b9e0bd490df2 to your computer and use it in GitHub Desktop.
copy files younger than x days to new location and delete files older than x there
#!/bin/bash
source='/srv/dev-disk-by-label-'
target='/srv/dev-disk-by-label-'
days=30
# delete
find ${target} -mtime +$days -type f -exec rm "{}" \;
find ${source} -mtime -$days -type f -exec cp -a "{}" ${target} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment