x=a/b/c/d y=a/ echo ${x#a/} echo ${x#$y} echo ${x#*/}