Last active
August 11, 2017 23:44
-
-
Save pmbuilder/b1c2dd07bb0da92d48c1633a9309c81f to your computer and use it in GitHub Desktop.
Find all hardlinks in tar files
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
#!/usr/bin/env python3 | |
import sys | |
import tarfile | |
if len(sys.argv) < 2: | |
print("usage: " + sys.argv[0] + " tarfile") | |
sys.exit(1) | |
path = sys.argv[1] | |
print("Listing all hardlinks in " + path + ":") | |
with tarfile.open(path, "r:gz") as tar: | |
for member in tar.getmembers(): | |
if not member.islnk(): | |
continue | |
print("* " + member.name + " -> " + member.linkname) | |
print("Done!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment