dissect_url 551B

12345678910111213141516171819202122232425262728293031
  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. ((i++))
  23. printf '=== url %02d =============================================\n' $i
  24. dissect
  25. done
  26. fi
  27. }
  28. main "$@"