A snippet to split string into an array. And shows you how to retrieve elements from the array. set -x STR="/path/to/a/config/file" TMP=$IFS IFS='/' WORDS=($STR) for ...