dissect_url 539B

123456789101112131415161718192021222324252627282930
  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. while read -r Url;
  20. do
  21. ((i++))
  22. printf '=== url %02d =============================================\n' $i
  23. dissect
  24. done
  25. fi
  26. }
  27. main "$@"