I have about a million files for which I need to get the filename, size, and date modified.
Is there any improvement that can be done, performance-wise, on the following command to get this information?
find ./ -exec ls -lh {} \;
Note: I can exclude files such as “.file”, “.trash/”, and any folders themselves (i.e., I only need the file information).
Update:
Here are the results:
$ time (find . -ls)
real 0m5.947s
user 0m0.393s
sys 0m0.682s
$ time (ls -lhR)
real 0m14.208s
user 0m0.978s
sys 0m2.510s
$ time (find ./ -exec ls -lh {} \;)
way too long
Yes, quite a bit. Faster alternatives include:
Running the
lscommand in larger batches than one file at a time:Having
finddo the file listing instead of a separatelscommand:Skipping
findaltogether and havinglsrun recursively: