Words after / symbol

Hi,

I have the following directory:

/home/dragon/websphere/cells/profile/imp/001/

I want to put this in a shell script and get the values before and after cells by removing the '/'

Any idea how to make this possible?

Regards,
Dinesh

Hi dbashyam,
can u plz tell what u want exactly...?

so u want the output as,

..?

Hi,

Actually I want to have the words before and after the word "cells"

Ofcourse it should include "/"

Thanks
Dinesh

try this

Use nawk if using solaris...

So, Are you looking for something like below..?

command:echo /home/dragon/websphere/cells/profile/imp/001/ | cut -d/ -f1-4,6-8

output:/home/dragon/websphere/profile/imp/001

If I understand your meaning:

$ STR="/home/dragon/websphere/cells/profile/imp/001/"
$ OLDIFS="${IFS}" ; IFS="/"
$ set -- $STR
$ IFS="$OLDIFS"
$ echo $1
home
$ echo $2
dragon
$ echo $3
websphere
$ echo "${!#}" # ${!#} doesn't work in all shells
001
$

There may be better ways to do this depending on your shell, ways which don't mean replacing the $1/$2/... you already have.

Post the sample output you expect from doing this.