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.

36 lines
811 B

  1. #!/bin/bash
  2. if [ $# -eq 0 ] ; then
  3. echo "Usage: $0 [-d|-i|-x] url" >&2
  4. echo "-d=domains only, -i=internal refs only, -x=external only" >&2
  5. exit 1
  6. fi
  7. if [ $# -gt 1 ] ; then
  8. case "$1" in
  9. -d) lastcmd="cut -d/ -f3 | sort | uniq"
  10. shift
  11. ;;
  12. -i) basedomain="http://$(echo $2 | cut -d/ -f3)/"
  13. lastcmd="grep \"^$basedomain\" | sed \"s|$basedomain||g\" | sort | uniq"
  14. shift
  15. ;;
  16. -x) basedomain="http://$(echo $2 | cut -d/ -f3)/"
  17. lastcmd="grep -v \"^$basedomain\" | sort | uniq"
  18. shift
  19. ;;
  20. *) echo "$0: unknown option specified: $1" >&2; exit 1
  21. esac
  22. else
  23. lastcmd="sort | uniq"
  24. fi
  25. lynx -dump "$1" | \
  26. sed -n '/^References$/,$p' | \
  27. grep -E '[[:digit:]]+\.' | \
  28. awk '{print $2}' | \
  29. cut -d\? -f1 | \
  30. eval $lastcmd
  31. exit 0