splitting up of absolute filepath

Hi,

I am using the bash shell on suse.I need to split the absolute file path 
into filename and directory path.

eg: /cas/43fg/temp/sample.txt

     i want to split the above into 
     sample.txt\(file\) and /cas/43fg/temp\(directory path\)

I want to do this by using shell commands.Would anyone help ?

A solution :

full_path=/cas/43fg/temp/sample.txt
file=$(basename $full_path)
dir=$(dirname $full_path)

Jean-Pierre.

full_path=/cas/43fg/temp/sample.txt
pth=$( echo ${full_path%/*} )
file=$( echo ${full_path##/*/} )

or

full_path=/cas/43fg/temp/sample.txt
pth=$( echo $full_path | sed "s,/[^/]*$,," )
file=$( echo $full_path | sed "s,/.*/,," )

All solutions are working fine,Thank you all for your valuable comment and time.

anbu,

would you pls explain the first solution of yours.It's working fine,but i am curious to know the chemistry.So pls.

pth=$( echo ${full_path%/*} )

Remove the shortest match from / to end of the input string

file=$( echo ${full_path##/*/} )

Remove the longest match /*/ from the start of the string

Why the $(..) and the echo ?

This will work as well.

pth=${full_path%/*}
file=${full_path##/*/}