read

This is just a collection of little scripts I search for on stack-overflow constantly. Now I'll know where to go to find them!

Python find current path

print(Path(__file__).resolve().parent)

Bash find current path

SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"

Or, if you care about sourcing:

ABSOLUTE_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/$(basename "${BASH_SOURCE[0]}")"
Blog Logo

Tom Kunc


Published

Image

tfpk

Back to Overview