Leonardo wrote:
> basename does not check if the file exists.
That's expected behaviour.
Use the test command to check file existence:
input=Desktop/okidoki
file=$(test -e "$input" && basename "$input")
[ "$file" ] && echo "$file" || echo "missing"
Pádraig.