cut the some part in filename

Hi All,

I have the file & name is "/a/b/c/d/e/xyz.dat"

I need "/a/b/c/d/e/" from the above file name.

I tryning with echo and awk. But it not come. Please help me in this regard.

Thanks & Regards,
Dathu

Maybe:

# pathAndFile="/a/b/c/d/e/xyz.dat"
# dirname "${pathAndFile}"
/a/b/c/d/e
# basename "${pathAndFile}"
xyz.dat
$ echo /a/b/c/d/e/xyz.dat | awk -F'/' '{print $NF}'
xyz.dat

Without external external commands:

var="/a/b/c/d/e/xyz.dat"

path=${var%/*}

file=${var##*/}