want the current directory without the absolute path

Hi guys

I'm trying to move an empty directory to the $TRASH directory. Say the directory i have is ./hello/hello1/hello2 and i'm in hello2, and i want hello2 moved.

this code:

TRASH=$home/deleted

find "$TRASH/$1" -type d -exec rmdir { } \; 2>/dev/null
mv -f $1 $TRASH 2>/dev/null

works when the $TRASH directory is empty, but if hello2 is already there it won't move it. So using find i'm trying to delete hello2 from $TRASH, but it won't because it's looking for the value of $1 which is the absolute path of hello2 ie ./hello/hello1/hello2, which of course isn't there.

Does that make sense?

The question is: is there a way to get the current directory without the ./hello/hello1/ bit? And if so, how! Or if not is there another way i can get the same result?

Many thanks in advance

Oliver

Try the basename command. Wil strip off anything except the last path segment.

Excellent, just what i was looking for!

Much appreciated

Oliver