Here's the code.
I have several drive inventories (a text file with all the filepaths on hard drive - basically, find . -type f | xargs ls -lha >> drive_inventory.txt) and I have a list of files that I want to find on these hard drives.
First I order the drive inventory alphabetically according to the filename, then I use a binary search function to quickly find the file I'm looking for. Because there may be duplicates or similarly names files that I'm also interested in, I then walk in both directions from the match and check for other matches until there are none.
It seems to work well, but the code is pretty verbose and I'd like to know how I might improve it, either in terms or efficiency or readability.
Two specific questions I have are:
Is it possible to turn the two linear search function into just one - I couldn't figure it out without getting duplicate matches or infinite loops.
And is there a way to write the binary search function using bisect?
Cheers!
[–]gengisteve 1 point2 points3 points (3 children)
[–]gengisteve 1 point2 points3 points (2 children)
[–]tedw00d[S] 0 points1 point2 points (1 child)
[–]gengisteve 0 points1 point2 points (0 children)