Created
October 25, 2013 00:38
-
-
Save us10096698/7147610 to your computer and use it in GitHub Desktop.
Get this Script's own Absolute Directory Path (Using `readlink -f` Command).
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 | |
mypath=`readlink -f $0` | |
mydir=`dirname $mypath` | |
echo $mypath | |
echo $mydir |
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 | |
TARGET_FILE=$1 | |
while [ "$TARGET_FILE" != "" ]; do | |
cd `dirname $TARGET_FILE` | |
FILENAME=`basename $TARGET_FILE` | |
TARGET_FILE=`readlink $FILENAME` | |
done | |
echo `pwd -P`/$FILENAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment