dissect_url 510B

1234567891011121314151617181920212223242526272829
  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. test -n "$Url" \
  17. && dissect \
  18. && return 0
  19. while read -r Url;
  20. do
  21. ((i++))
  22. printf '=== url %02d =============================================\n' $i
  23. dissect
  24. done
  25. }
  26. main "$@"