'get folder name with find ... -name command in bash

Trying to get name of venv folder for activating it in bash script located inside the project. Because someone could use for venv another name like 'someones_env'

projectdir=$(cd ../../ && pwd)
echo "$(dirname "$projectdir")"

venvdir=$(find "$(dirname "$projectdir")" -name '*env')
echo "$(dirname "$venvdir")"

source "$(dirname "$venvdir")"/bin/activate

but $venvdir becomes the same as $projectdir instead of 'someones_env'

what am i doing wrong? thanks



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source