I have a directory with possibly around 800,000 files in it.
What is the fastest way to list file(s) in this directory with a wildcard.
for example would
ls -1 *.abcdefg.Z
or
find . -name "*.abcdefg.Z"
be the fastest way to find all of the files that end with .abcdefg.Z in this directory with 800,000 files in it.
Any help or sugestion would be greatly appreciated.
Looks like ls -1 is faster than find command.
Here are the results.
time ls -1 *.00abcdefg.Z
ABC.00abcdefg.Z
AB.00abcdefg.Z
real 0m2.05s
user 0m0.88s
sys 0m0.96s
time find . -name "*.00abcdefg.Z"
./ABC.00abcdefg.Z
./AB.00abcdefg.Z
real 33m43.95s
user 0m3.02s
sys 0m29.87s
I am a bit surprised, since I would have imagined the find to be faster. However if there is some other mechanism other than ls -1 available I would be open to trying that as well. Thanks for your input.
You type that command into an interactive shell. Your interactive shell will see *.abcdefg.Z and do all of the work of searching the directory to expand that pattern into a list of files. Once it replaces the pattern with that list it is ready to run that "time" command....