#!/usr/bin/env python """Show Symlinks recursively for a given path or paths""" import os, sys def ShowSymlinks(paths=[]): """Show Path Tree with Symlink Information""" l = [] if not paths: return -1; for path in (os.path.normpath(x) for x in paths): if os.path.exists(path): if os.path.isdir(path): for root, dirs, files in os.walk(path): for f in files: if not f in l: l.append(os.path.normpath("%s/%s" % (root, f))) for d in dirs: if not d in l: l.append(os.path.normpath("%s/%s" % (root, d))) else: if not path in l: l.append(path) l.sort() for path in l: if os.path.islink(path): print "%s -> %s" % (path, os.readlink(path)) if __name__ == "__main__": if len(sys.argv) > 1: paths = sys.argv[1:] else: print "Usage: %s pathname1 (pathname2 ...)" % (sys.argv[0]) sys.exit(0) ShowSymlinks(paths)