Email this to a friend
 
posted on August 23rd 2010, at 16:47
by lunarg

For a shell script to determine its own location, you can use this code snippet. It takes relative and absolute paths into account.

#!/bin/bash
if [[ $0 == '/'* ]]; then
	MYLOCATION="`dirname $0`"
else
	MYLOCATION="`pwd`"/"`dirname $0`"
fi
echo "My location is: $MYLOCATION"

Send a link to this post to yourself or a friend.

Send to e-mail:
Your name:
Your e-mail:
Captcha:
Type the letters and numbers as shown.
/get/captcha/1711725334
Not readable? Get another.
 
Information entered is solely used for sending a one-time e-mail, and is not retained and/or passed on to a third party.
 
 
 
 
« March 2024»
SunMonTueWedThuFriSat
     12
3456789
10111213141516
17181920212223
24252627282930
31      
 
Links
 
Quote
« If the batteries of a TV remote run out, why do we press the buttons so much harder? »