Giter Site home page Giter Site logo

learnbyexample / learn_gnugrep_ripgrep Goto Github PK

View Code? Open in Web Editor NEW
305.0 10.0 35.0 4.79 MB

Example based guide to mastering GNU grep and ripgrep

Home Page: https://learnbyexample.github.io/learn_gnugrep_ripgrep/

License: MIT License

Python 0.16% Shell 99.84%
ebook gnu grep ripgrep regex command-line learning-by-doing exercises linux

learn_gnugrep_ripgrep's Introduction

CLI text processing with GNU grep and ripgrep

Example based guide to mastering GNU grep and ripgrep. Visit https://youtu.be/MSbGokwHm-A for a short video about the book.

CLI text processing with GNU grep and ripgrep ebook cover image

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

For solutions to the exercises, see Exercise_solutions.md.

You can also use this interactive TUI app to practice some of the exercises from the book.

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


E-book

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 pdfs from markdown using pandoc if you are interested in the ebook creation process.

For the web version of the book, visit https://learnbyexample.github.io/learn_gnugrep_ripgrep/


Feedback and Contributing

⚠️ ⚠️ Please DO NOT submit pull requests. Main reason being any modification requires changes in multiple places.

I would highly appreciate if you'd let me know how you felt about this book. It could be anything from a simple thank you, pointing out a typo, mistakes in code snippets, which aspects of the book worked for you (or didn't!) and so on. Reader feedback is essential and especially so for self-published authors.

You can reach me via:


Table of Contents

  1. Preface
  2. Introduction
  3. Frequently used options
  4. BRE/ERE Regular Expressions
  5. Context matching
  6. Recursive search
  7. Miscellaneous options
  8. Perl Compatible Regular Expressions
  9. Gotchas and Tricks
  10. ripgrep
  11. Further Reading

Acknowledgements

Special thanks to all my friends and online acquaintances for their help, support and encouragement, especially during difficult times.


License

The book is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

The code snippets are licensed under MIT, see LICENSE file.

learn_gnugrep_ripgrep's People

Contributors

learnbyexample avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

learn_gnugrep_ripgrep's Issues

typo...probably :)

On this page https://learnbyexample.github.io/learn_gnugrep_ripgrep/perl-compatible-regular-expressions.html#modifiers

In the example code you wrote:
$ # allow . metacharacter to match newline character as well
$ printf 'Hi there\nHave a Nice Day' | grep -zoP '(?s)the.*ice'
there
Have a Nice

Shouldn't it be
$ # allow . metacharacter to match newline character as well
$ printf 'Hi there\nHave a Nice Day' | grep -soP '(?s)the.*ice'
there
Have a Nice

Regards and thank you for the beautiful book

[README] Grammar issues

One

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

  • Reason: subject is exercises, which is plural

Two

See https://learnbyexample.github.io/books/ for a list of other books

  • Reason: list is countable

Three

See my blogpost on generating pdfs from markdown using pandoc if you are interested in the ebook creation process.

  • Reason: pdf is countable; you can say a pdf or pdfs

Four

For the web version of the book, visit https://learnbyexample.github.io/learn_gnugrep_ripgrep/

  • Reason: web is countable

[buy pdf/ebook versions] Grammar issue

Here's a list of programming books I've written (or am currently working upon on):

  • Reason: currently needs an auxiliary verb; it can't use the have in I've. Also, we don't say working upon a book.

[preface] English mechanics

One

You are likely to be familiar with using Ctrl+F from an editor, word processor, web browser, IDE, etc ., to quickly locate where a particular string occurs.


Two

grep is a similar, but much more versatile and feature-rich version of the that search functionality usable from the command line.

  • Reason: We're being told that grep is a functionality, that is, a countable noun; it requires an article. Also, the is not the right word to refer to the Ctrl-F search functionality, since the is indefinite, but we need the definite.

Three

Modern requirements have given rise to tools like ripgrep that provide out-of-box features such as recursive search while respecting the ignore rules of a version controlled directory.

  • Reason: ignore rules is not a mass noun here, since it refers to ones that belong to some single version controlled directory.

Four

Understanding both the nature of sample input string and the output produced is essential.

  • We shouldn't say this. Sample input string is treated as a mass noun without an article, while output is treated as definite. Hence, the sentence lacks parallelism. There are different ways to fix this. I'm not sure how you'd like it done.

Five

As an analogy, consider learning to drive ride a bike or drive a car

  • Reason: We ride bikes and drive cars.

Six

Should you feel that copy-paste is ideal for you, code snippets are available chapter wise chapter-wise on GitHub.

  • Reason: See adverb combining form here

Seven

My Command Line Text Processing repository includes a chapter on GNU grep , which has been edited and expanded to create this book.

  • Reason: a comma is needed before which, see here

Eight

Prior experience working with the command line and bash shell , . You should know concepts like file redirection, command pipeline , and so on.

Reason: command line and bash shell require an article; they're not mass nouns. This sentence was also comma-spliced.


Nine

If you are new to the world of the command line, check out my curated resources on Linux CLI and Shell scripting before starting this book.

Reason: Same as eight


Ten

I would highly appreciate it if you'd let me know how you felt about this book , . it It would help to improve this book as well as my future attempts. Also, please do let me know if you spot any error errors or typo typos.

  • Reason: appreciate is a transitive verb and needs an object. There's also a comma-splice. Lastly, error and typo are countable.

Eleven

You can find his other works, primarily focused on the Linux command line, text processing, scripting languages and curated lists, at https://github.com/learnbyexample. He has also been a technical reviewer for the Command Line Fundamentals book and video course published by Packt.

  • Reason: command line is not a mass noun. Also, it doesn't really make sense to say "my work is focused on curated lists". Perhaps people work on curating lists (they work on doing something, i.e., curating), but they don't work on the finished (curated) lists themselves. Lastly, books are countable.

Typo - Page 77

Page 77
Paragraph 1
Line 4

Actual text :

"behavior varies wrt GNU grep in terms
of features"

Expected text :
"behavior varies with GNU grep in terms
of features"

PS : Thanks a lot for your quality work and the open access you gave to it. I'll try to stay alert and report any other typo or suggestions that may enter my mind.

Wrong Count on Chapter 2: Question g

The question:

Find total count of whole word the (irrespective of case).

$ grep ##### add your solution here
8090

does not return 8090, but rather 7941:

20221121_162154

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.