From time to time I'll use the unix find -newer command to snag a list of file and folders modified after some other reference file. I'll redirect the output of find to a text file, which now contains all folders and files I'm interested in.
I then would like to work with these files and folders at the shell. Yesterday I needed to split the master listing into two disjoint lists; one of all folders, one of all files. It's fairly easy to create a list of the folders if you don't care about empty folders. Just chop off each trailing element of each line, then sort the text file and pipe it into uniq.
Files are a bit trickier though. Here's the command I always forget about:
comm -23 all.txt folders.txt
From the man page: The comm utility reads file1 and file2, which should be sorted lexically, and produces three text columns as output: lines only in file1; lines only in file2; and lines in both files.
So, comm neatly partitions text files organized by lines by finding and printing the intersection of the files.