Skip to content

Instantly share code, notes, and snippets.

@nlitsme
Last active August 29, 2015 14:08
Show Gist options
  • Save nlitsme/72477017d171a50d98c2 to your computer and use it in GitHub Desktop.
Save nlitsme/72477017d171a50d98c2 to your computer and use it in GitHub Desktop.
list timemachine copies of a file
#!/bin/bash
bkdir=
while [[ -n "$1" ]]; do
cd $(dirname "$1")
realpath=$(pwd -P)
case "$realpath" in
/Volumes/*)
realpath=${realpath:9}
;;
*)
realpath="$realpath"
;;
esac
ls -id /Volumes/*/Backups.backupdb/*/20*/*"$realpath/$(basename "$1")" | perl -nle 'if (/^\s*(\d+)\s(.*)/ && !$x{$1}++) { print $2; }'
shift
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment