<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'>> Another issue is that some filenames have '-' in them, but the module<br>> names have '_' in them. <br><br>This is a problem because the modules filenames are a mess. Some<br>filenames have an underscore '_' too.<br><br><br>> Does the current solution filter out<br>> duplicates due to the modulename and filename not being the same<br>> (i.e. '-' vs. '_')?<br><br>If you want to get <br><br>(all available mods) minus (already loaded mods)<br><br>a solution is to change hyphen '-' to underscore '_' in the filenames,<br>but not the opposite. This is because the output of "lsmod" or <br>"/proc/modules" is always with underscore. <br><br>I try this modification (and renaming) of you functions<br><br>---------------------------------------<br>function _sort_all_mods {<br>   find /lib/modules/$(uname -r) -type f -name \*.ko|sed 's|.*/||g;s|[.]ko$||'|sort -u|tr - _<br>}<br><br>function _loaded_mods_regexp {<br>   local a<br>   a=$(awk '{print $1}' /proc/modules|sort -u|sed 's/^/^/;s/$/$/'|tr "\n" '|')<br>   echo ${a%|}<br>}<br><br>function _newmods {<br>   declare cur prev words cword<br>   _get_comp_words_by_ref cur<br>   COMPREPLY=( $(compgen -W "$(_sort_all_mods|grep -E -v "$(_loaded_mods_regexp)")" -- "$cur" ) )<br>}<br><br>complete -F _newmods modprobe<br>---------------------------------------<br><br>Using the functions above I get the right filtering<br><br>$ _sort_all_mods | wc -l<br>2542<br><br>$ _loaded_mods_regexp | tr '|' "\n" | wc -l<br>79<br><br>$ _sort_all_mods | grep -E -v "$(_loaded_mods_regexp)" | wc -l<br>2463<br><br>$  echo 2542 - 79 | bc<br>2463<br><br><br>> So sounds like using a modified function based on the function<br>> I used and your optimizations would "ignore" the problem of the<br>> extra links?<br><br>Your solution works because uses command "find", which ignore links<br>by default. I mean, "find" is equivalent to "find -P".<br><br><br>Regards,<br><br>FA<br><br></div></body></html>