> - X2GO_COMPONENT="$(echo "${compfile}" | cut -d '.' -f '2')" > + X2GO_COMPONENT="$(echo "$(basename ${compfile})" | cut -d '.' -f '2')" The echo $(...) is redundant, i.e., you want X2GO_COMPONENT="$(basename "${compfile}" | cut -d '.' -f '2')"