<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: times new roman,new york,times,serif; font-size: 12pt; color: #000000'>Thanks for  your message.<br><br>> I find it useful<br>> to have modprobe default to listing only modules that are NOT loaded<br>> yet.<br><br>For the default use, when loading a module, this is the case. The<br>command modprobe has also an "-r" option to unload the module,<br>and in this case it would complete to the already loaded modules.<br><br>To fix the slowness issue you can just remove the "-L" option from command "ls".<br>I try this and it works. I try also your code and works too.<br><br><blockquote id="DWT6035" style="border-left:2px solid rgb(16, 16, 255);margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;">I can't say how long it would take to complete on debian following<br>a bunch of symlinks</blockquote>There are just 2 symlinks. But they point to the kernel (compilated) source<br>directory, which has a size of 5 GB. Hence, listing this directory twice takes<br>a lot of time.<br><br><blockquote style="border-left:2px solid rgb(16, 16, 255);margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;">but on my system, it takes about a tenth of a second<br>to come up with a list of 376 possible modules on my system, so unless<br>there is something odd about the list on debian, it might be faster..?<br></blockquote>In my system I have 2542 modules:<br><br>$ _clean_n_sort_mods  |  wc -l<br>2543<br><br>The number 2543 is because this function also matches an emtpy line at<br>the beginning. This is the performance of the function<br><br>$ time _clean_n_sort_mods >/dev/null<br><br>real    0m0.130s<br>user    0m0.085s<br>sys     0m0.042s<br><br>Note that when I use this<br><br>function _clean_n_sort_mods {<br>   find /lib/modules/$(uname -r) -type f -name \*.ko | sed 's|.*/||g;s|[.]ko$||'<br>}<br><br>I get<br><br>$ time _clean_n_sort_mods >/dev/null<br><br>real    0m0.021s<br>user    0m0.024s<br>sys     0m0.009s<br><br>For the second function I get<br><br>$ time _loaded_mods > /dev/null<br><br>real    0m0.011s<br>user    0m0.001s<br>sys     0m0.011s<br><br>Note that this function uses 3 commands (lsmod, tail and sed).<br><br>When I use this<br><br>function _loaded_mods {<br>   awk '{print $1}' /proc/modules<br>}<br><br>I get<br><br>$ time _loaded_mods > /dev/null<br><br>real    0m0.002s<br>user    0m0.001s<br>sys     0m0.001s<br><br>In the function _newmods you can replace the pipe "sort | uniq -u" by the single command "sort -u".<br><br>Regards,<br><br>FA<br> <br></div></body></html>