Tech Forums

Getting the Parent Directory name in shell

User Rating:  / 0
PoorBest 

Q. I have a veriable called “SOCE”

set SOCE = “/servers/tools/SOCEncounter/tools.lnx86/bin/encounter”

Now I want to have

set SOCE = “/servers/tools/SOCEncounter/tools.lnx86/bin”

As you can see there is no “/encouner” at the end…..


Ans. set NEW_SOCE = $SOCE:h
now the variable NEW_SOCE will have the value “/servers/tools/SOCEncounter/tools.lnx86/bin”

set SOCE = $NEW_SOCE

OR

set NEW_SOCE = `dirname $SOCE`

Site Login