#!/bin/bash dissect() { echo $* | perl -pe ' s|(\w)(/[^/])|$1\n $2|; s|\?|\n ?\n |; s|#|\n #\n |; s|&|&\n |g;' echo "" } main() { local url=$1 local i=0 if [[ -n "$url" ]]; then dissect "$url" else i=0 while read url; do if [[ -z "$url" ]]; then exit 0; fi i=`expr $i + 1` printf "=== url %02d =============================================\n" $i dissect "$url" done fi } main "$@"