Mastering GNU grep and ripgrep

learnbyexample profile image Sundeep Updated on ・2 min read


I recently published my book on GNU GREP and RIPGREP and it is free to download till 19-May-2019! You can still pay if you wish :)

grep cover image

Get the e-book using either of these sites:

Note Please use a valid e-mail and save the mail you receive, you'll get free updates for future versions.

Code snippets, example files, sample chapters, etc are available on

GitHub logo learnbyexample / learn_gnugrep_ripgrep

Example based guide to mastering GNU grep and ripgrep


Example based guide to mastering GNU grep and ripgrep.

The book also includes exercises to test your understanding, which is presented together as a single file in this repo - Exercises.md

See Version_changes.md to keep track of changes made to the book.


You can purchase the book using these links:

For a preview of the book, see sample chapters

The book can also be viewed as a single markdown file in this repo. See my blogpost on generating pdf from markdown using pandoc if you are interested in the ebook creation process.


Please open an issue if you spot any typo/errors.


This book covers features of GNU grep and ripgrep along with discussion on BRE/ERE/PCRE(2)/Rust regular expressions. Examples are used extensively, please follow along by typing them out. Exercises are also included to test your understanding.

Some of you might be familiar with my Command Line Text Processing repo.

GitHub logo learnbyexample / Command-line-text-processing

⚡ From finding text to search and replace, from sorting to beautifying text and more 🎨

Command Line Text Processing

Learn about various commands available for common and exotic text processing needs. Examples have been tested on GNU/Linux - there'd be syntax/feature variations with other distributions, consult their respective man pages for details.

⚠️ 🚧 Work in progress, stay tuned...


Rough drafts

Possible additions - seems like these won't be coming any time soon :(

  • Parsers for html, xml, csv, json, etc
  • Renaming files
  • other commands like split, combine, datamash, etc


  • Please open an issue for typos/bugs/suggestions/etc
    • Even for pull requests, open an issue for discussion…

This book is based on the grep chapter - edited to add more descriptions, better examples, exercises, etc. Also, I took the plunge and checked out ripgrep while working on this book. I'd assumed it would be similar to gnu grep and I just need simple changes to present it in the book. Well, it turned out lot more work and I had to settle for not covering all the options and customizations. In hindsight, would've been better if I did a separate book. Speed wise, ripgrep is very impressive and has plenty of additional nice features. For example: the multiline -U and replace -r options of ripgrep are quite handy - you can use this instead of sed for some cases with added advantage of speed, -F option and better regex features.

Table of Contents

  • Preface
  • Introduction
  • Frequently used options
  • BRE/ERE Regular Expressions
  • Context matching
  • Recursive search
  • Miscellaneous options
  • Perl Compatible Regular Expressions
  • Gotchas and Tricks
  • ripgrep
  • Further Reading

Hope you find the book useful. I would be grateful for your feedback, book review and suggestions.

Happy learning :)

PS To celebrate the release, I'm also offering my e-book on Python regular expressions for half the price during the offer period. Use these coupon links gumroad or leanpub to get it.

Posted on by:

learnbyexample profile



Addicted to writing books and teaching. Likes fantasy books, comics and anime


Editor guide

If it it's a book on grep, it better be one line per page. But seriously grep is great one of the more curious programs. IL be checking this out, thank you.


haha, cool, happy learning :)

Seriously, this has 100+ pages - I've tried to cover most of the options provided by GNU grep and I left out few topics am not experienced enough (like locale settings, multicolor, etc). There are two big chapters on BRE/ERE and PCRE regex. And there's a chapter on ripgrep too, plus exercises.. so you can see how pages kept growing


Fantastic! Thank you sir!


Thanks for checking it out, happy learning :)