tc@box:~/remdir$ tc@box:~/remdir$ cat orig.lst /usr/local/lib/usr/local/include/zbuff.h/usr/local/lib/pkgconfig/libzstd.pc/usr/local/include/zdict.h/usr/local/usr/local/include/zstd.h/usr/usr/local/lib/pkgconfig/usr/local/include/usr/local/include/zstd_errors.htc@box:~/remdir$ tc@box:~/remdir$ ./RemoveDirs orig.lst tc@box:~/remdir$ tc@box:~/remdir$ cat stripped.lst /usr/local/include/zbuff.h/usr/local/include/zdict.h/usr/local/include/zstd.h/usr/local/include/zstd_errors.h/usr/local/lib/pkgconfig/libzstd.pctc@box:~/remdir$ tc@box:~/remdir$The list is first sorted. Each line is then tested to see if it's a substring of the next line. If you have /usr/local then local has tobe either a file or a subdirectory, it can't be both. So if /usr/local is a substring of the next line, then it's a directory and getsdiscarded.

I knew the links would be that way when I tested it. I didn't know if that would be useful information or a problem, depending on how the resulting file list is used. Adding another regex to sed will clear that up:

unsquashfs -ll -d '' svn.tcz | grep -v '^d' | sed -e 's#.* /#/#' -e 's# -> .*##'A question I also thought of when I was cobblling my script together is whether or not directories should be included if they are empty. No directories will be listed thanks to grep.

I guess empty directories should be included if they actually exist and are required for things to work, but this would almost never be the case as empty directories under /var, etc should be created by a startup script.