If PATH always absolute, you can do tricks, for example
ROOT=${PATH#/} ROOT=/${ROOT%%/*}
or
IFS=/ read -ra T <<< "$PATH" ROOT=/${T[1]}
However, I must add to this that it is better to use other variables and not use PATH , as this will change your search directories for binaries if you really do not intend.
You can also convert your path to absolute form via readlink -f or readlink -m :
ABS=$(readlink -m "$PATH")
You can also refer to my getabspath function.
source share