I was going through shell script wriiten by someone else. I could see below lines at starting of the script. i know it has to do something with path and all. But can anyone explain about it how it works?
#!/bin/ksh
scripttorun=${0}
scriptname=${0##/*/}
scriptname=$(basename $0)
scriptpath=${0%%/$scriptname}
if [ $scriptpath != $0 ];then
cd $scriptpath
fi