Re: Path extract issue



tester wrote:
test1 -> /home/vb/test1
test2 -> /home/vs/test2
test3 -> /home/test3
Hi chris,
Tahnks for the reply however this will leave only the last field and
the output is: test1 or test2 or test3 but i am looking for output as :
home/vb or /home/vs or /home
path=/home/vs/test2
dir=${path##*/}


At least in these circumstances*, you can also use dirname(1), e.g.:
dir=`dirname -- "$path"`

*don't try to relocate a HOME directory of / or a HOME directory that
ends with / ... probably prudent to sanity check the pathnames before
making assumptions about them.

references:
dirname(1)
sh(1)
basename(1)
sed(1)
awk(1)
news:ue1ti3-gab.ln1@xxxxxxxxxxxxxxxxxx
news:1146868485.572423.34030@xxxxxxxxxxxxxxxxxxxxxxxxxxxx

.