On Fri, Dec 14, 2012 at 07:59:13PM -0500, Aaron Schrab wrote: > + > + commit=` echo $version|sed -e's/.*-//'` > + version=` echo $version|sed -e's/-[^-]*$//'` > + > + distance=`echo $version|sed -e's/.*-//'` > + version=` echo $version|sed -e's/-[^-]*$//'` > + > + version=` echo $version|sed -e's/^mutt-//' -e's/-rel$//' -e'y/-/./'`
You can probably achieve the required fied separation by setting IFS=- and getting the shell to split the string. Maybe something like (untested): save_ifs="$IFS" IFS=- set -- x-$version shift # remove the 'x' added in case $version empty IFS="$save_ifs" # I think the script now wants the last two subfield removed, # an inital "mutt-" removed and the '-' replaced with '.' [ "$1" = mutt ] && shift ver="$1" while [ $# -gt 2 ]; do [ "$1" != rel ] && ver="$ver.$1" shift done distance="$1" commit="$2" Removing the last two fields is the tricky part! The '-' could be replaced with '.' by just doing: IFS=- set -- $version IFS=. version="$*" David -- David Laight: da...@l8s.co.uk