Filtering redundant paths from a list of paths

view full story

http://unix.stackexchange.com – I have a list of relative paths such as this: dir1 dir2 dir2/dir3 dir2/file1 dir3/file2 dir3/dir4 dir3/dir4/file3 In the example above, the specifier dir2/file1 (for example) is redundant, because the dir2 entry would include this file. Want I want to do, essentially, is remove redundant paths from a given list of paths. The above example would output the following: dir1 dir2 dir3/file2 dir3/dir4 Note that the files and directories specified need not actually exist on the filesystem. I am willing to use any common Unix command (sed, awk, perl, etc.). (HowTos)