Last active
February 25, 2019 14:22
-
-
Save Loriowar/274f5363877413bfdbcf5a4b8a804eba to your computer and use it in GitHub Desktop.
Recursively find directories excluded from Time Machine backup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#NOTE pass a path as a first argument, i.e. `./recursive_tmutil.sh ~/` | |
find $1 -type directory -exec tmutil isexcluded {} + \ | |
| grep -F "[Excluded]" \ | |
| sed -E 's/^\[Excluded\][[:space:]]*//' \ | |
| awk '{ print length, $0 }' \ | |
| sort -n -s \ | |
| cut -d" " -f2- \ | |
| awk ' { if(length(res) == 0) { res[$0] }; mark=0; for(r in res) { if(match($0, r)== 1){ mark=1; break } }; if(mark==0) res[$0] } END { for (i in res) print i } ' \ | |
| sort |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment