Ad
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
Ad
Answer
The directory of the *env
folder is the project directory, that's why dirname "$venvdir"
becomes the same as the project directory. Without dirname
it should work.
Also, the directory of ../../
is ../../../
, this might also be giving you some issues. If you are already in a directory, there's no need to use dirname
. dirname
calculates the parent directory.
Ad
source: stackoverflow.com
Related Questions
- → "Box: laravel/homestead-7" producing "sh.exe":box:: command not found"
- → Retrieve user's image selection from website
- → Getting error when using default task in gulp, shows the following error in Gitbash : Task requires a name that is string
- → Homestead Installaton
- → bash: homestead: command not found
- → Troubles with Artisan Tinker encoding
- → How can I access declared variable in bash when executing Laravel Envoy task?
- → coinex exchange API and use Curl /BASH to Place a market order crypto pair
- → Coiex API Curl Could not resolve host
- → How to GREP words, not lines, that contain specific characters, and print entire word
- → Cmd and Git bash have a different result when run a Python code
- → How can I convert ip ranges formatted in ip1-ip2 to cidr format?
- → Pushing to another user's remote repository without the use of pull requests
Ad