You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
752 B

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