Skip to content

Instantly share code, notes, and snippets.

@sc68cal
Last active December 12, 2015 02:38
Show Gist options
  • Save sc68cal/4699799 to your computer and use it in GitHub Desktop.
Save sc68cal/4699799 to your computer and use it in GitHub Desktop.
Tarsnap archive pruner Usage: `tarsnap --list-archives | python cleanup.py | xargs -n1 tarsnap -df `
#!/usr/bin/env python
import sys
keep = {}
for line in sys.stdin.readlines():
mountpoint = line.rfind("-")
if not line[:3] + line[mountpoint:] in keep:
keep[line[:3] + line[mountpoint:]] = line
else:
sys.stdout.write(line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment