#YOURSTRING="this_is_an_example" #output: #this #is #an #example for i in $(echo $YOURSTRING | tr "_" " ") do echo $i done