Comments
 
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"
 
 
« February 2025»
SunMonTueWedThuFriSat
      1
2345678
9101112131415
16171819202122
232425262728
 
Links
 
Quote
« Debating Windows vs. Linux vs. Mac is pointless: they all have their merits and flaws, and it ultimately comes to down to personal preference. »
Me