UNIX comand

Team,

I need unix command to grep directory part from the string
for example I have a texts something like

/apps/opt/data/current/spool/test.dbf
/apps/opt/archive/../../test.dbf

I need only directory part from that string
like my out put will

/apps/opt/data/current/spool/
/apps/opt/archive/../../
echo "/apps/opt/data/current/spool/test.dbf" | awk -F"/" '{ print $NR}'

will display file name. But I need only path

by example through bash/korn shell remove right most syntax...

[josephgr@oc0887178221 ~]$ x="/foo/bar/file.txt"
[josephgr@oc0887178221 ~]$ echo ${x%/*}
/foo/bar