[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

trying to optimize find's searches ...



find works significantly faster when you bag various search patterns á la:

-iname '*.ko' -or -iname '*.bin' -or -iname '*.txt'

but, how could you do that using a batch strategy and setting a
variable with many "-[i]name ... -or -[i]name ..." cases?

line-by-line strategies are too slow

lbrtchx

$ _ODIR="<...>"

$ _SDIR="<...>"
$
$ _OFL="$_ODIR/$(basename "$_SDIR")_$(date +%Y%m%d%H%M%S)_fs_ko_bin_txt.log"
$ (time sudo find "${_SDIR}" -type f -iname '*.ko' -or -iname '*.bin'
-or -iname '*.txt')  > "${_OFL}" 2>&1
$
$ wc -l "${_OFL}"
1216 /media/sda6/tmp/sda1_20160304192857_fs_ko_bin_txt.log
$ tail -n 4 "${_OFL}"

real    0m2.274s
user    0m1.457s
sys 0m0.773s

$ _OFL="$_ODIR/$(basename "$_SDIR")_$(date +%Y%m%d%H%M%S)_fs_ko.log"
$ (time sudo find "${_SDIR}" -type f -iname '*.ko')  > "${_OFL}" 2>&1
$
$ wc -l "${_OFL}"
4 /media/sda6/tmp/sda1_20160304193029_fs_ko.log
$ tail -n 4 "${_OFL}"

real    0m1.526s
user    0m0.697s
sys 0m0.807s

$ _SDIR="/media/sda1"
$
$ _OFL="$_ODIR/$(basename "$_SDIR")_$(date +%Y%m%d%H%M%S)_fs_txt.log"
$ (time sudo find "${_SDIR}" -type f -iname '*.txt')  > "${_OFL}" 2>&1
$
$ wc -l "${_OFL}"
1213 /media/sda6/tmp/sda1_20160304193057_fs_txt.log
$ tail -n 4 "${_OFL}"

real    0m1.641s
user    0m0.757s
sys 0m0.797s

$ _OFL="$_ODIR/$(basename "$_SDIR")_$(date +%Y%m%d%H%M%S)_fs_bin.log"
$ (time sudo find "${_SDIR}" -type f -iname '*.bin')  > "${_OFL}" 2>&1
$
$ wc -l "${_OFL}"
7 /media/sda6/tmp/sda1_20160304193127_fs_bin.log
$ tail -n 4 "${_OFL}"

real    0m1.535s
user    0m0.750s
sys 0m0.763s


Reply to: