dissect_url 565B

1234567891011121314151617181920212223242526272829
  1. #!/bin/bash
  2. dissect() {
  3. echo $* | perl -pe '
  4. s|(\w)(/[^/])|$1\n $2|;
  5. s|\?|\n ?\n |;
  6. s|#|\n #\n |;
  7. s|&|&\n |g;'
  8. echo ""
  9. }
  10. main() {
  11. local url=$1
  12. local i=0
  13. if [[ -n "$url" ]]; then
  14. dissect "$url"
  15. else
  16. i=0
  17. while read -r url;
  18. do
  19. if [[ -z "$url" ]]; then exit 0; fi
  20. i=`expr $i + 1`
  21. printf "=== url %02d =============================================\n" $i
  22. dissect "$url"
  23. done
  24. fi
  25. }
  26. main "$@"