Skip to content

Instantly share code, notes, and snippets.

@cpaulbond
Created June 15, 2016 15:24
Show Gist options
  • Save cpaulbond/a7205cf70b472b56d7b9f0a67da96b07 to your computer and use it in GitHub Desktop.
Save cpaulbond/a7205cf70b472b56d7b9f0a67da96b07 to your computer and use it in GitHub Desktop.
Different ways to get the directory of the script.
#!/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