dirname, save cut portion to variable, clean up

Hi guys, last cry for help for today. I appreciate the help so far.

ok so I have a program that dumps a path into my script as a variable ($1)
This path is an example
/home/xbmc/sab_downloads/video/tv/grey's anatomy/season 3

So in order to search thetvdb.com for a show, I need to extract the show name to pass to the other portions you guys have been helping me with so far today. The show name in the path will always be correct and there may often be spaces. I know I can truncate the last dir from the path using dirname but in this case I need to keep the show name.

the beginning of the path:
/home/xbmc/sab_downloads/video/tv

will always be the same with no exceptions however there may not always be anything trailing the name of the show, for example:
/home/xbmc/sab_downloads/video/tv/example

How can I truncate the name of the show in this environment and save it to a variable?

Thanks in advance!

if you have this

/home/xbmc/sab_downloads/video/tv/example

and you want

/home/xbmc/sab_downloads/video/tv

in some variable use

 
var=`dirname /home/xbmc/sab_downloads/video/tv/example`

or
if you have

/home/xbmc/sab_downloads/video/tv/grey's anatomy/season 3

and first part remains same try this

 
var=`echo "/home/xbmc/sab_downloads/video/tv/grey's anatomy/season 3"|sed 's/\(\/home\/xbmc\/sab_downloads\/video\/tv\/\)\(.*\)/\1/g' `

The shell has parameter expansion that can do what you want; there is no need for an external command:

path="/home/xbmc/sab_downloads/video/tv/grey's anatomy/season 3"
showseason=${path#/home/xbmc/sab_downloads/video/tv/}
show=${showseason%/*}

hey vid

the only part that will always remain the same is

/home/xbmc/sab_downloads/video/tv

after that the path changes, the first dir after "tv" is what I want to save to a variable

So if I have

/home/xbmc/sab_downloads/video/tv/test example

the part I want to save to a variable is

test example

If I have

/home/xbmc/sab_downloads/video/tv/grey's anatomy/season 3

I can use dirname to get rid of "season 3" leaving me with

/home/xbmc/sab_downloads/video/tv/grey's anatomy

At this point what I want to save to a variable is "grey's anatomy"

The main goal is to take the path and save the show's title to a variable

In that case you can use cfajohnson solution

cfa! this works brilliantly, can you give me a quick rundown of what you did here, I am interested in how this works

Read the "Parameter Expansion" section of your shell's man page (or the POSIX Parameter Expansion page, or chapter 1 of my book, Shell Scripting Recipes, or any of the many tutorials on the web).