Browse Source

Add Bash Safe Parent Dir

Schnippet to safely get the parent directory of a Bash script.
master
Nate Bohman 3 years ago
parent
commit
41969752d8
Signed by: Nate Bohman <natrinicle@gmail.com> GPG Key ID: C10546A54ABA1CE5
1 changed files with 6 additions and 0 deletions
  1. +6
    -0
      bash_parent_dir.sh

+ 6
- 0
bash_parent_dir.sh View File

@@ -0,0 +1,6 @@
#!/usr/bin/env bash

# Get the parent dir to the one this script is located in.
base_dir=$(dirname -- "$(dirname -- "$(realpath -- "${0}")")")

echo "${base_dir}"

Loading…
Cancel
Save