#!/bin/bash URI=("/some/path_including/under_score.txt" "/some/other/path/with_score.txt" ) for x in ${URI[@]}; do F=${x##*/} B=${x%/*} echo "${B}/${F/\_/ }" done