DEV Community

Mike Whitaker
Mike Whitaker

Posted on • Edited on

6 1

Shell command options you didn't know you needed #2

(another in an occasional series)

grep -m <matches>

One of the many handy options to grep (there'll be quite a few in this series), the -m option controls how many matches are displayed for each file grep scans.

For (hypothetical) example:

grep -m 1 '^sub' *.pm # find the first sub definition in each file

Top comments (1)

Collapse
 
raagpc profile image
raag pc

Good, grep is really handy

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay