From esselfe, 6 Years ago, written in Bash.
This paste is a reply to Re: lmbf.sh / lvu find from esselfe - view diff
Embed
  1. #!/bin/bash
  2. # Script to find Lunar module by partial name
  3. # time { lmbf sdl disk part system util data xml prog; } gave me
  4. # 94ms for the moonbase and 11ms for the module.index, great
  5.  
  6. find_module_index() {
  7.     NSTR="-e \"$1\""
  8.  
  9.     if [ ! -z "$2" ]; then
  10.         shift
  11.         for MODNAME in "$@"; do
  12.             NSTR="$NSTR -e \"$MODNAME\""
  13.         done
  14.     fi
  15.  
  16.     echo "NSTR: $NSTR"
  17.     bash -c "grep -i $NSTR /var/lib/lunar/moonbase/module.index"
  18. }
  19.  
  20. find_module_mb() {
  21.     NSTR="-iname \"*$1*\""
  22.  
  23.     if [ ! -z "$2" ]; then
  24.         shift
  25.         for MODNAME in "$@"; do
  26.             NSTR="$NSTR -o -iname \"*$MODNAME*\""
  27.         done
  28.     fi
  29.  
  30.     cd /var/lib/lunar/moonbase
  31.     bash -c "find * -type d $NSTR"
  32. }
  33.  
  34. find_module_index "$@"
  35. #find_module_mb "$@"
  36.