Search Bear notes using `grep` command With grep, I can search through the content of all the files in a directory, for an instance:

grep 'program' *.md


searches for the pattern program within the content of all .md files in the current directory.

How do I search the Bear notes in Terminal using thegrep command?
You can use the same grep command as mentioned in the question, to search through the contents of .md files exported by Bear. For instance, use

grep pattern *.md

to search for pattern in .md files in the current directory. You can use -i option to ignore case or -n to print line number in file.