Skip to main content
2 of 2
added 119 characters in body
kryn
  • 3
  • 2

How to pretty output of grep for searching within markdown files?

I have a knowledge base (aka Zettelkasten) of markdown files. And I use searching with the next command grep -irn 'search request' *.md. All works fine.

But I'd like see output with the title of the file and sub header of the found string.

The sample

file.md

1 # Title 2 3 ## Subtitle 4 5 yada-yada 

Output

> grep -irn 'yada' *.md < file.md:5:Title:Subtitle:yada-yada 

Can I do this with grep without multiple search in the file?

An analogue of recall for terminal would be ideal.

kryn
  • 3
  • 2