Whole word with sed?

Hi experts,

need a help in SED

file=counter.c
module=abcd
i=http://svn.company.com/svn/${module}/trunk/counter/${file}

When i do

echo ${i}| sed "s|http://svn.company.com/svn/${module}/trunk/||g"| sed "s|${file}||g"

it results in

ounter.c

wherein the expected is

counter/

Can anyone pls help here

$> echo $i
http://svn.company.com/svn/abcd/trunk/counter/counter.c
$> echo $i| sed 's|.*/\([^/]\{1,\}\/\)[^/]*|\1|g'
counter/

Or:

$ echo 'http://svn.company.com/svn/abcd/trunk/counter/counter.c'|
sed 's|.*/\(.*/\).*|\1|' 
counter/
$

you can use "cut" instead.

echo ${i}| sed "s|http://svn.company.com/svn/${module}/trunk/||g" | cut -d"/" -f2

The problem was in your last sed statement:

sed "s|/${file}||g"

A more efficient way is:

$ j=${i%/*}
$ echo ${j##*/}
counter

thanks all for your replies..

i tried all your commands.. it works well for counter and anything after trunk if that is a directory.. But i have many of these url's with filenames..

Ex:
i=http://svn.company.com/svn/abcd/trunk/counter/counter.c
i=http://svn.company.com/svn/abcd/trunk/xyz.xml
i=http://svn.company.com/svn/abcd/trunk/mno/scripts/diary/example.java

What i had tried to accomplish from my initial commands is to basically take out the filenames ($file) and http://svn.company.com/svn/abcd/trunk from $i. So that i can get as below:

1) counter/
2) this should give me a blank because there is nothing found after removing http://svn.company.com/svn/abcd/trunk/ and xyz.xml
3) mno/scripts/diary/

So that i can create directories of whatever is left out. In case of 2, i will create it on the parent directory where the command is running.. So i thought if i can just take out the $file and http://svn.company.com/svn/abcd/trunk , it should give me the dirs..