#!/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 if [[ -n "$Url" ]]; then dissect else i=0 while read -r Url; do ((i++)) printf '=== url %02d =============================================\n' $i dissect done fi } main "$@"