#!/bin/bash dissect() { # # Print "dissected" version of $Url # echo "$Url" | perl -pe ' s|(\w)(/[^/])|$1\n $2|; s|\?|\n ?\n |; s|#|\n #\n |; s|&|&\n |g;' echo "" } main() { local Url=$1 local i=0 test -n "$Url" \ && dissect \ && return 0 while read -r Url; do ((i++)) printf '=== url %02d =============================================\n' $i dissect done } main "$@"