Grep util last occurrence

I have file contents

/tmp/x/abc.txt
/home/bin/backup/sys/a.log

I need this output:

/tmp/x/
/home/bin/backup/sys/

Can somebody please help me out

Isn't that what the command dirname does? It only does one line at a time, though.

P.S. This is another way:

sed 's/\/[^\/]*$//' 

The final operand (not shown) is the name of your input file.

that worked

ty

/ at the end needed?

A couple more ways from the many ways to skin the cat:

awk '{$NF=_} 1' FS=/ OFS=/ file
while read line ; do echo "${line%/*}/" ; done < file