MonkeyWordSearch - Powerful, Free Linux Keyword-search Utility!
4/28/2015 09:41:00 PM
Jsc Jwhat Jerome Christopher
, Posted in
Bash Search Script
,
GNU Linux
,
javascript tips
,
Linux
,
Linux Search Tool
,
Search Utility
,
Shell Scripts
,
Sqlhtm Tools
Searching for a free search program(Linux bash script) with GUI input controls? Want to see results on your browser? Love keyword highlighting? Need to see not just result fragments from file but the file itself? Want to restrict searches to ASCII/text files only but need to view list of files that weren't searched also? Want a clickable link for EVERY FILE with or without a match within the domain of the search? Want to see the progress of the search with an oscillating progress bar and a scrolling percentage-completed tailbox?
Welcome to MonkeyWordSearch! The Monkey's got it all for you!
Read on.
REQUIREMENTS
1.Zorin7 OS [Ubuntu] Linux2.A modern browser that supports CSS3 transitions [I used Chrome28.0, Firefox28.0, Opera12.16]
3.Zenity [I used version 3.6.0]
4.GNU Awk 4.0.1
5.Rxvt v2.6.4
Screen resolution: 1280 x 800 [Recommended]
FEATURES
MonkeyWordSearch is a powerful recursive keyword search utility with GUI input box, file select control, file-type and maxdepth filters which let you search files on your Linux PC/Laptop for your search phrases. It's features are listed below.
1.View results on browser: Display the search results on the browser.
2.Highlight keywords/search phrase[Case-insensitive!]: Highlight the keywords within search results for emphasis. You'll like it that Monkey displays a match regardless of whether it is UPPERCASE, lowercase or CamelCase!
3.List text files with/without result: Locate and separately list which files contain results and which do not.
4.List non-text(skipped) files: Locate and separately list skipped non-text/ASCII files.
4a.Here's something even more interesting.
Click on the [Clickable File List] button to view the clickable version of the same page useful for viewing pdfs, images etc but remember to NOT CLICK on executable or very large files.
5.Display results as Encoded or Normal: Click anywhere inside the result box or click on the [View Results] link above the result box to display the results page that pops up for text-view or web-view of the search results. While the top [HTML-Encoded text view] is always intact, remember that the bottom [Normal HTML web view] below it may sometimes seem broken since incomplete HTML code in search results might make it look broken. This is normal behavior. Click on the [Result Fragments: Normal] button on top of the page TWICE to bring up the normal section to top.
6.View search file itself, not just results: Click on the [View File] link on the top-right of the search result box to view the file on the browser. If this link did nothing, then the filename may have goofy characters in it and, most often we can click either on the search result box or the [View Results] link and then click on the link to the file on top of the results page. If this didn't work either, at least we have the filename parts with the path so we can open the file manually.
7.Exclude big files from search but view their names: Exclude big files [greater than 5MB] from the search but view their names.
8.Find search progress percentage-completed [MonkeyWordSearchTailbox window]
How do I activate/de-activate this window? This window is activated by default. To de-activate it, find and comment these two lines in the [$HOME/tools/MonkeyWordSearch/Mws.bash] file.
[You may activate it again by uncommenting the two lines above if you choose to.]
How is it useful? Once you press [OK] on the 4th and final input box, you see this window if it is activated. This Rxvt terminal window with a fast-scrolling tailbox displays the total file count, percentage-completed, current file being processed with path among other things.
How do I exit from it? Press [CTRL-C] from within this window to exit from it. Double-click on [$HOME/tools/MonkeyWordSearch/MwsCleanup.bash] script to terminate MonkeyWordSearch completely. Find more details at the [III.Termininating MonkeyWordSearch] section below.
Is there a search log? Remember to check the [$HOME/tools/MonkeyWordSearch/MwsSearchLog.htm] file for the complete record of the search after the search completes.
9.MonkeyWordSearch window: Once you press [OK] on the 4th final input box, this [oscillating progress-bar] window starts up along with the [MonkeyWordSearchTailbox] window. Along with keyword and other input parameter details, you can also view the search progress with an oscillating progress bar. You may stop and exit from the Monkey before it completes by pressing [Escape] from within this window and pressing [Ctrl-C] from the MonkeyWordSearchTailbox window. Don't forget to cleanup strays with [$HOME/tools/MonkeyWordSearch/MwsCleanup.bash] before re-running the Monkey!
10.Use 4 GUI input boxes: These are used for inputs. Press [Escape] to exit.
NOTE 1: LINUX COMMANDS AND TOOLS USED
You wouldn't believe it that a simple program such as MonkeyWordSearch needs so many Linux commands and tools to fetch you the results! First you need to manually verify or set 4 files at the top of the $HOME/tools/MonkeyWordSearch/Mws.bash script. Change samples below to suit your environment. #Define your browser location below BROWSER=/usr/bin/chrome #Define awk location below AWK=/usr/bin/awk #Define rxvt location below RXVT=/usr/bin/rxvt #Define zenity location below ZENITY=/usr/bin/zenity Apart from these, there are 17 Linux commands/tools Monkey needs. You may appreciate the fact that Monkey automatically scans and sets the locations of these following essential Linux commands without you having to manually check each one of them. When you run Monkey, one of the first things it does is to check for these 17 files and error out if it misses anything. If MonkeyWordSearch doesn't start up, open the [$HOME/tools/MonkeyWordSearch/MwsMissing.out] file to view the details of found and not found files and fix the problems if any and re-run Monkey after fixing problems. Here's the list of these mostly standard and almost always available 17 Linux commands/tools: mkdir bash mv rm touch echo grep cat sed find sleep file wc expr bc cp sort
NOTE 2: SIZE OF EXCLUDE FILES
While leaving out non-text/ASCII files, Monkey also excludes text files bigger than 5MB from being searched but lists their names so you can search those big files manually if you choose to. You can change the default big file size by searching for and changing the line below in the Mws.bash script if [ $fsize -le 5242880 ]; then
NOTE 3: OPENING FILES FROM MONKEYWORDSEARCH BROWSER LINKS OR BUTTONS
MonkeyWordSearch has made it easy for you to be safe when you click on files to open them from the browser by segregating non-text/ASCII files and excluding them from being searched. Again, even among text/ASCII files it picks out and excludes files bigger than 5MB from being searched. Best of all, MonkeyWordSearch presents you a skipped(non-text) files page with non-clickable list of file names by default, but you can make it clickable by pressing the button just above the list. Talk about having the best of both worlds, safety and convenience! As a general rule of thumb, though, ALWAYS exercise caution when clicking on links because of the way browsers make file-associations. For example, don't click on executables, huge files etc.
NOTE 4: BROWSE YOUR SEARCH FOLDER WITH YOUR BROWSER!
Click on the link to the right of [Search Location] on the top of the main search result page to browse the search folder with your browser.
NOTE 5: X-RAY-MONKEY: MONKEY FOUND A RESULT BUT I CAN'T FIND IT IN THE FILE - HEY WHAT'S UP?
The result box shows a match but when you open the file and search for it you don't find it, what's going on? This may happen when you're searching html files where there could be matches found in non-content areas such as html code or javascript code. If you're opening the html search file with your browser, rightclick and select [view page source] and then press [CTRL-F] to do a search and you'll find it.
NOTE 6: [ViewFile] LINK ON TOP-RIGHT OF SEARCH RESULT BOX WON'T WORK - HEY WHAT'S UP?
If the [ViewFile] link on the top-right of the search result box doesn't open the file, the filename possibly has some weird characters. Click inside the result box to open the results page on a new tab/window and click on the link on the top of the page to open the file. If this doesn't work either, at least we have the path and filename of this rogue! Just open it with your file manager.
NOTE 7: RESULTS FROM A ZIP FILE IS SHOWING UP IN THE RESULT BOX - HEY WHAT'S UP?
Sometimes you may see results from zip files shown in the result box. This may be normal. If a html file is compressed into a zip file, it may be seen as "HTML document, UTF-8 Unicode text, with very long lines" by the [file] command that is used to filter text/ascii files. In this case, the file may be opened by a text editor.
NOTE 8: SMART IDEA - SAVE THAT SEARCH!
Let's say you just searched for files with the keyword [Linux] and want to save it for future. Just copy the [Mws.htm] file and rename it to something such as [Mws.linux.htm]. This will benefit especially those who keep their stuff well-organized on their PC/Laptop since they will have only one two places to search for anything! Isn't this a good idea?
NOTE 9: DUMB SEARCHES[?]
1.Avoid searching system folders if you don't intend to.[Eg. /var, /usr, /etc etc.] 2.If you delete lots of files using PcManFM GUI file manager, then your [/root/.local/share/Trash] folder for root user or [$HOME/.local/share/Trash] folder for non-root users may be huge. Remember to avoid searching these if you don't intend to. 3.Your [$HOME/.thumbnails] folder may have tens of thousands of files, you may not want to search these.
CONCLUSION
This Monkey sure made me go all bananas! Seriously, it took a lot of time and effort to get it going but it sure will make your life easy if you choose to use it! MonkeyWordSearch makes searching files on your Linux system for keywords a much better experience first since it lets you view results on your browser with keyword highlighting. Secondly you can view not just the results but the file itself. Thirdly you get a clickable list of files with results and those without. Fourthly you get a clickable list of skipped(non-text) files. And most of all, it lets you view the progress of the search the whole time while letting you terminate it INSTANTLY with just a double-click on [$HOME/toos/MonkeyWordSearch/MwsCleanup.bash] then clicking [Open] or by typing [mwsclean] from the commandline!Here's the secret. Once you get used to typing [mws] and [mwsclean] from the commandline or its equivalent of double-clicking on [$HOME/toos/MonkeyWordSearch/Mws.bash] and [$HOME/toos/MonkeyWordSearch/MwsCleanup.bash] and then clicking [Open] to start and terminate the Monkey, I guarantee you'll be using them all the time without knowing it!