#!/bin/bash listName=$1 if [ -n "$listName" ]; then debug.log "list: $listName" list="${!listName}" else list=$PATH debug.log "list: PATH " fi shift loopcommand=$1 if [ -n "$loopcommand" ]; then debug.log "loopcommand is: -$1-" shift else loopcommand="echo " debug.log "command is echo... " fi if [ -n "$loopcommand" ]; then debug.log executing: $loopcommand listItems for line in ${list//:/ } do debug.log executing: $loopcommand $line $* $loopcommand $line $* done else read -p "loopcommand? " loopcommand $0 $list $loopcommand fi