$ find /path/to -mindepth 1 -maxdepth 1 -exec sh -c ' [ -d "$1" ] && printf "%s/\n" "${1##*/}" || printf "%s\n" "${1##*/}" ' _ {} \; aDirectory/ afile Explanations:
[ -d "$1" ], this checks if its a directory, if yes then run followedprintf:printf "%s/\n" "${1##*/}"
else, run below printf:
$ find /path/to -mindepth 1 -maxdepth 1 -exec sh -c ' [ -d "$1" ] && printf "%s/\n" "${1##*/}" || printf "%s\n" "${1##*/}" ' _ {} \; aDirectory/ afile ${1##*/}: this removes longest match of everything*till last slash/seen start from begging of the file/directory path, which it will result only last directory/file name only.