|
Apro + Pos by Matt Giwer ©2001 |
|---|
|
Update -- the cooperative linux spirit Scroll down to the original and try it. Slow but it works and for me was faster than going through a long list of useless matches. For some reason I contacted the people at Linux Gazette and got into an email exchange which lead to sending them my original below. One of the "Two Cent Tips" folks decided he could do better and he did sending me the script below.
#!/bin/bash
# Created by Ben Okopnik on Mon Nov 19 21:47:39 EST 2001
[ -z "$1" ] && { printf "Usage: ${0##*/}
It works the same way but is almost as fast as apropos itself. Original When you first use linux you need to learn the commands for doing the simple things and there are plenty of short writeups of the basic commands. After a while you want to do more and you learn of apropos. And then you learn more than you ever imagined is included in linux distributions. And you are very happy someone told you about using the shift key with the arrow keys to scroll scroll the screen. Or maybe you started doing apropos | less. As you learn more you search for more and find how many program desctriptions contain words like convert and ascii. And then you have to tediously read every output to see if you do have what you need or ... #/bin/bash # this puts the search words into temporary files # and then outputs only the results which are in both files apropos $1 > xxx1 ; apropos $2 > yyy2 ; grep -x -i -f xxx1 yyy2 # remove the temporary files rm xxx1 ; rm yyy2 Always out to save keystrokes I name this script apro. It is used as apro word word and shows only the description which contain both words. On my machine apropos ascii gives 31 results and apropos convert gives 424 results. You can crawl through those if you like but I do apro convert ascii and get only the 12 results which contain both words. If you are not interested in routines you can't use from the command line on pages other than man1 pages you can do apro ascii 1 and reduce the 31 results from apropos ascii to just 11. That is more than enough refinement for most cases but you can go wild and extend it to three words searches with this used as apro3 word word word. #/bin/bash apropos $1 > xxx1 apropos $2 > yyy2 apropos $3 > zzz3 grep -x -i -f xxx1 yyy2 > ttt1 grep -x -i -f ttt1 zzz3 rm xxx1 ; rm yyy2 ; rm zzz3 ; rm ttt1 But my experience has been it usually gives no results for failing to pick the right words and apro most always gives a half screen or fewer matches so searching on three words not worth the hassle of guessing words. But apro3 convert ascii 1 gives only those usable from the command line which has some use. As usual these two can be combined into one general purpose script with any number of search words and can be greatly improved by those with real experience in shell scripting. © the article only of course. Pardon a gnubie for almost forgetting to clarify that.
Page reads: 6820
|