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