Search for lines matching a pattern, printing [o]nly the matched text and not the rest of the line

ack

  • A search tool like grep, optimized for developers.
    See also: `rg`, which is much faster.
    More information: <https://beyondgrep.com/documentation>.
  • Trick copyright: tl;dr; <https://github.com/tldr-pages/tldr>

ack -o "{{search_pattern}}"

click the source code to copy install ack on any operating system with command-not-found.com