#!/bin/bash
BIN_FOLDER=$(cd "$(dirname "$0")";pwd)
echo $BIN_FOLDER
PROJECT_FOLDER=$(cd "$(dirname "$BIN_FOLDER")";pwd)
echo $PROJECT_FOLDER
PYTHON_BIN=$PROJECT_FOLDER/.venv/bin/python
echo $PYTHON_BIN
-
BIN_FOLDER = $(cd "$(dirname "$0")",pwd) 解析:
-
1、取当前运行脚本的所在路径: $0
-
2、取当前脚本所在路径的父目录: dirname "$0"
-
3、取返回的父目录的值: $(dirname "$0")
-
4、cd到返回的父目录: cd "$(dirname "$0")"
-
5、输出地址: cd "$(dirname "$0")",pwd
-
6、取输出的地址,并赋值给BIN_FOLDER: BIN_FOLDER = $(cd "$(dirname "$0")",pwd)