This website works better with JavaScript.
Home
Explore
Help
Register
Sign In
natrinicle
/
schnippets
Watch
1
Star
0
Fork
0
Code
Issues
0
Pull Requests
0
Releases
0
Wiki
Activity
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
1954dc8490
commit
41969752d8
Signed by:
Nate Bohman
<natrinicle@gmail.com>
GPG Key ID:
C10546A54ABA1CE5
1 changed files
with
6 additions
and
0 deletions
Split View
Show Diff Stats
+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}"
Write
Preview
Loading…
Cancel
Save