This is for a bash installation script. The script foo.sh takes \"DIRECTORY\" as an argument. Say, there is a dir <$HOME>/TEST/TEST_1A/TEST_2A/TEST_3
and anot
You could try:
if [[ "$1" == */* ]]; then
EXPR="-path *$1"
else
EXPR="-name $1"
fi
DIR=$(find $HOME -type d $EXPR | head -1)
A simple name like "TEST_3" will translate into find -name TEST_3
but a name with a slash like "ST_2/TEST_3" will translate into find -path *ST_2/TEST3
. This will take care of (partial) directory names.