Created
August 26, 2011 14:51
-
-
Save rduplain/1173578 to your computer and use it in GitHub Desktop.
Answering: how can I reference the scripts directory and the working directory in GNU bash?
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/bash | |
# `dirname` is part of GNU coreutils, but is okay to use since it's in the Unix standard. | |
DIRNAME=`dirname $0` | |
echo script is at $DIRNAME | |
# Alternative, use pure bash substitution. | |
DIRNAME=${0%/*} | |
echo script is at $DIRNAME | |
# bash sets the current working directory in PWD | |
echo you are at $PWD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment