unix console: how to delete lines that contained in other lines

I have a text file that contains sorted paths e.g.

/abc
/abc/def
/abc/jkl
/def
/def/jkl
/def/jkl/yui
/def/xsd
/zde

now I’d like to delete lines that contained in other lines in this case following lines should stay:

/abc/def
/abc/jkl
/def/jkl/yui
/def/xsd
/zde


Source: unix

Leave a Reply