#!/bin/bash args= command="echo" for file; do if [ "$file" = "-c" ]; then command= elif [ "$command" = "" ]; then command=$file else if [ "${file:0:1}" != "/" ] ; then #non-absolute path file="`pwd`/$file" fi args="$args $file" fi done if [ "$args" ]; then $command $args else echo "Usage: $0 [-c command-to-run] [file2 ... fileN]" fi