1#! /usr/bin/env python3 2 3# Find symbolic links and show where they point to. 4# Arguments are directories to search; default is current directory. 5# No recursion. 6# (This is a totally different program from "findsymlinks.py"!) 7 8import sys, os 9 10def lll(dirname): 11 for name in os.listdir(dirname): 12 if name not in (os.curdir, os.pardir): 13 full = os.path.join(dirname, name) 14 if os.path.islink(full): 15 print(name, '->', os.readlink(full)) 16def main(args): 17 if not args: args = [os.curdir] 18 first = 1 19 for arg in args: 20 if len(args) > 1: 21 if not first: print() 22 first = 0 23 print(arg + ':') 24 lll(arg) 25 26if __name__ == '__main__': 27 main(sys.argv[1:]) 28