Because cracksmoking MacOS likes to change the names of drive mounts unpredictably (mostly by adding things like “-1” and “-2” to them) when it gets confused, I had to use globbing to reliably identify a mounted volume/directory in my Bash scripts. Here’s what I did:
for VOL in /Volumes/myvol*; do
# Check if it's actually a directory
if [[ -d "$VOL/mydl/thisdir/here" ]]; then
DEST="$VOL/mydl/thisdir/here"
break
fi
done
This finds the first item named “myvol” and in a later part of the script not excerpted here slaps what you want in there. But warning: this snippet like Cisco stuff takes action immediately on the first match only, so if you might have more than one match just be aware of that and modify as needed.