Skip to content

Instantly share code, notes, and snippets.

@lambdalisue
Last active September 26, 2015 19:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lambdalisue/1145772 to your computer and use it in GitHub Desktop.
Save lambdalisue/1145772 to your computer and use it in GitHub Desktop.
Get absolute execution directory path in Sh
#!/bin/sh
# --- long way
ROOT=`dirname $0`
ROOT=`cd $ROOT;pwd`
# --- short way
ROOT=$(cd $(dirname $0);pwd)
# --- with readlink
SELF=$(readlink -f $0)
ROOT=$(dirname $SELF)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment