Created
June 15, 2016 15:24
-
-
Save cpaulbond/a7205cf70b472b56d7b9f0a67da96b07 to your computer and use it in GitHub Desktop.
Different ways to get the directory of the script.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#>> Different ways to get the directory of the script. | |
echo ${0%/*} | |
echo $(cd ${0%/*} && pwd) | |
if [[ ${0%/*} = "." ]] | |
then echo $PWD | |
else echo ${0%/*} | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment