Skip to main content

Get the path/director and filename of the currently executing Bash script file.

#!/usr/bin/env bash

script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
script_filename="$(basename "${BASH_SOURCE[0]}")"

echo "this bash script's dir is .......: $script_dir"
echo "this bash script's file name is..: $script_filename"