On Thu, 2007-10-04 at 05:03 +0100, Steve Long wrote: > Donnie Berkholz wrote: > > > spec=$(echo ${CHOST} | cut -d- -f3) > > > You can do this without resort to an external process: > IFS=- > read _ _ spec _ <<< "$CHOST" > unset IFS > - or you can do: > IFS=- > arr=($CHOST) > unset IFS > spec=${arr[2]}
See, another use of bash arrays just because you can? IFS=- set -- ${CHOST} spec=$2 Works fine in bash - and other shells. You need to preserve IFS when changing it, however. Unless of course, you're doing this in a function so you can just local IFS=- Here's a snippet from b2's localmount init script. IFS=${IFS} SIFS=${IFS-y} FS=$IFS: for x in ${NO_UMOUNTS} ${RC_NO_UMOUNTS} ; do no_umounts="${no_umounts}|${x}" one if [ "${SIFS}" = "y" ] ; then IFS=$OIFS else unset IFS fi Thanks Roy -- [EMAIL PROTECTED] mailing list