Static Website search

Looking for a way to add “search” to a static site. I considered using grep offline on the html pages. Then referencing the web page. But grep gave me problems. I have to assume that with something used as much as grep, the problems were due to my misuse. Be that as it may, if I can’t get it to do what I want then for this purpose it is useless

Grep

Success!
logfile/posts$ grep -il "vm/" *.html
339.html
345.html
457.html

Success!
logfile/posts$ grep -i "vm/" *.html
339.html:<h1>VM/370 emulation</h1>
339.html:   Ran VM/370 in a IBM S/370, ESA/390, and z/390 hardware emulator on Linux.
345.html:   Today I'm more comfortable using MVS in Hercules emulation than VSE and VM. Mostly because MVS didn't take as much work as VM/DOS to actually do something useful. It was more useful as they say...out of the box.
457.html:<h1>IBMs VM/370</h1>
457.html:   Continuing retro. Now using the hercules emulator for IBM Mainframes and also the 3270 terminal emulator. Here's VM/370,  IBM's first version, released in 1972...way before Linux knew what a VM was or, for that matter, the world knew what Linux was. This is very much like the VM systems I was employed to maintain...
$ 

Right now I have all posts in one directory, but I’m considering breaking them up in subdirectories by year. So I need to be able to search the directories recursively.

So much for recursive search working
This from the help….
-r, --recursive           like --directories=recurse

logfile$ ls -la
total 116
drwxrwxr-x  3 bill bill  4096 Aug 28 14:45 .
drwxr-xr-x 35 bill bill  4096 Aug 25 18:52 ..
-rw-rw-r--  1 bill bill  2846 Aug 22 18:23 about.html
-rw-r--r--  1 bill bill  3832 Aug 28 14:45 grep.txt
-rw-r--r--  1 bill bill 59270 Aug 25 21:59 index.html
drwxrwxr-x  2 bill bill 36864 Aug 25 21:59 posts	Subdirectory one up

Failure!
logfile$ grep -r "vm/" *.html
logfile$ 		Nothing returned!

I read something saying grep has a problem with wildcards, so...

Failure!
logfile$ grep -r "vm/" .
logfile$		Again nothing returned!


I read that grep has something to do with REs  global regular expression
So why did “VM/” work in the 1st examples?

However (finally on my own research) I suspected the slash…
As you can see below “escaping” the forward slash worked, However I didn’t escape it above...and it worked! That’s inconsistent!

logfile$ grep -ril "vm\/" .
./index.html
./posts/339.html
./posts/345.html
./posts/457.html
logfile$ 

Finally. I read you can use the “-F” switch to do a regular, non-regex search. But that didn’t work either!

Supposedly you can avoid regexs by using -F. However…

Failure!Failure!Failure!Failure!
logfile$ grep -r "vm/" .
logfile$ grep -Fr "vm/" .
logfile$ grep -r --fixed-strings "vm/" .
logfile$ grep -F -r  "vm/" .


Finally I just wrote a ~40 line Python program that does what I want. As you can see it recursively searched 2 directories. Now was that so hard?

(base) bill@bill-MS-7B79:~/Mystuff/Python3$ ./pyFind.py 
Enter string to search for: vm/
Searching for: vm/
Found in: logfile/posts/342.html
Found in: logfile/posts/453.html
Found in: logfile/posts/336.html
Found in: logfile/index.html

Files searched  458
(base) bill@bill-MS-7B79:~/Mystuff/Python3$