Re: Path extract issue
- From: "Michael Paoli" <michael1cat@xxxxxxxxx>
- Date: 7 May 2006 01:15:46 -0700
tester wrote:
Hi chris,test1 -> /home/vb/test1
test2 -> /home/vs/test2
test3 -> /home/test3
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
.
- References:
- Path extract issue
- From: tester
- Re: Path extract issue
- From: Chris F.A. Johnson
- Re: Path extract issue
- From: tester
- Path extract issue
- Prev by Date: Re: howdoIwrite2AgroupWritableFile;echo hi>foo #fails,touch wrks
- Next by Date: Re: concatenate files
- Previous by thread: Re: Path extract issue
- Next by thread: awk for a cleaner approach
- Index(es):