One alternative:
for name in subdir/*; do basename "$name"; done for name in subdir/*; do basename "$name"; done for name in subdir/subsubdir/*; do
echo "${name#subdir/}" # subsubdir/foo
doneEdit: It turns out that Bash does substitutions in the middle of strings using the ${string/substring/replacement} and ${string//substring/replacement} syntax, for more details see https://tldp.org/LDP/abs/html/string-manipulation.html