8 ms·
Show HN: I wrote a book on GNU grep and ripgrep
My book on "GNU grep and ripgrep" is free to download today and tomorrow [1][2]
Code snippets, example files and sample chapters are available on GitHub [3]
The book uses plenty of examples and regular expressions are also covered from scratch. The book is suitable for beginners as well as serves as a reference. Hope you find it useful, I would be grateful for your feedback and suggestions.
I used pandoc+xelatex [4] to generate the pdf.
[1] https://gumroad.com/l/gnugrep_ripgrep https://gumroad.com/l/gnugrep_ripgrep
[2] https://leanpub.com/gnugrep_ripgrep https://leanpub.com/gnugrep_ripgrep
[3] https://github.com/learnbyexample/learn_gnugrep_ripgrep https://github.com/learnbyexample/learn_gnugrep_ripgrep
[4] https://learnbyexample.github.io/tutorial/ebook-generation/customizing-pandoc/ https://learnbyexample.github.io/tutorial/ebook-generation/c...
- dewey 7y agoSlightly related, I only recently found out that the grep (BSD) included in macOS is way slower than the GNU equivalent that you can install from Homebrew. If you ever had to work with big files and were confused why it's so much slower give it a try. http://jlebar.com/2012/11/28/GNU_grep_is_10x_faster_than_Mac_grep.html http://jlebar.com/2012/11/28/GNU_grep_is_10x_faster_than_Mac...
- teraflop 7y agoRelated, from 2010: "why GNU grep is fast" (https://lists.freebsd.org/pipermail/freebsd-current/2010-August/019310.html https://lists.freebsd.org/pipermail/freebsd-current/2010-Aug...)
- asicsp 7y agoI've also seen questions on unix.stackexchange like [1][2] that BSD grep has been buggy for some common usecases [1] https://unix.stackexchange.com/questions/398223/grep-strange-behaviour-with-single-letter-words https://unix.stackexchange.com/questions/398223/grep-strange... [2] https://unix.stackexchange.com/questions/352977/why-does-this-bsd-grep-result-differ-from-gnu-grep https://unix.stackexchange.com/questions/352977/why-does-thi...
- opencl 7y agoAnd ripgrep is quite a lot faster than GNU grep[1], especially if you need unicode support. [1] https://blog.burntsushi.net/ripgrep/ https://blog.burntsushi.net/ripgrep/
- dewey 7y agoIt depends, I benchmarked all of the usual suspects (fgrep, GNU grep, BSD grep, ripgrep, sift grep) on the same 30GB line separated JSON file last week and GNU grep was the fastest one. I didn't have a scientific testing setup though. I just ran them one by one like this: time cat title_complete_json.txt | grep tt9184994 >> result
- Scarbutt 7y agoThe infamous "useless use of cat"
- adrusi 7y agoThat's relevant in some scripts, where unnecessary forks might actually add up to some meaningful resource usage. Not relevant when typed at a tty.
- nsajko 7y agoTo clarify, it would have been prettier (conceptually less clunky and shorter) to run this: time grep tt9184994 < title_complete_json.txt >> result
- catucia 7y agogrep takes a file directly, so this could simply be: time grep tt9184994 title_complete_json.txt >> result
- hyper_reality 7y agoIt annoys me whenever somebody brings this up. People do this because it's easier to modify commands at the end of your prompt than near the beginning. Especially in this case, where the grandparent wants to quickly switch between benchmarking grep, ripgrep etc. Not useless at all.
- s_dev 7y agoThis is true of quite a few tools. https://www.topbug.net/blog/2013/04/14/install-and-use-gnu-command-line-tools-in-mac-os-x/ https://www.topbug.net/blog/2013/04/14/install-and-use-gnu-c...
- dingo_bat 7y agoWhy are you giving it away for free? Just curious, not trying to troll.
- sachdevap 7y agoIt's a common model recently to get word of mouth publicity for the book, to get some reviews to get the book off the ground.
- chris_wot 7y agoI paid, mostly because you were actually giving it away for free.
- asicsp 7y agoMany reasons. Mainly to get feedback and reviews as mentioned by another user. I don't have a prominent blog or social media account, so getting users is quite difficult for me. I'm inspired by people like Al Sweigart and Allen Downey who provide excellent content on Python for free. I'd also like to open source my books sometime in future.
- cryo 7y agoEnjoyed the example chapter very much and just ordered via Gumroad. Thanks, already learned a few new things which will be handy in future.
- iamnotacrook 7y agoThis should be run past an editor. The text is missing articles (a, an, the) all over. Something obviously got lost in translation. It's fine for a blog or comment on HN or whatever but if you're asking for money...
- sa46 7y agoSomewhat off topic, how would one go about getting good technical editing for something like a blog post or for a book like the OP? Is it expensive?
- timClicks 7y agoPost an add for a "development editor" who specializes in technical writing on upwork/similar. You get what you pay for.
- m463 7y agoI've always wondered why book reader software didn't have a "hightlight and submit typo feedback" function right up front. Of course, that might lead to "crowdsourced" editing, which might be a horrible thing to create.
- kirke 7y agoYou know you really don't need to tear down his work because you don't like the way it reads. Lots of the missing articles are around command line arguments, where the correct usage is ambiguous anyway. I don't find it distracting. The content of these books is an excellent resource on an immeasurably useful topic. As for "... but if you're asking for money...," this post is literally giving away his work. The consumer is given the option to pay nothing, or whatever is reasonable according to their own valuation. If you as the consumer value the work less because it fails to conform to language rules, then you are actually invited to decrease the compensation given by you to the author.
- rmbryan 7y agoPlease please please hire an editor. You have good content that needs editing.
- asicsp 7y agoYep, this is a consistent feedback I've got for my books. I'll try to get them edited, at least the obvious mistakes like missing articles.
- jrumbut 7y agoVery nice work! What was your writing process, and did you make any arrangements before getting started? One of my forever back-burner projects is a deep(ish) dive like this into one of the tools that a lot of us kind of know how to use. I'm glad to see you went and did it!
- asicsp 7y agoThanks. My case is kinda weird one. I left my job after just 6 years in corporate world, due to various reasons. To cut a long story short, I went through depression, trying various things which didn't work out, etc. I conduct basic cli/scripting workshops at college, so I tried improving my materials - got active on stackoverflow, reddit, etc and started maintaining repos on github [1] It grew and finally last year I got the courage to try and self publish my tutorials collected for 2+ years in the form of books. 'deep dive' is a nice way to sum it up, it is amazing that there's so much to write about a tool. I knew probably about 5-10 grep options when I was at my job, and didn't know regular expressions that well. So, being able to write a book with confidence is such a satisfying experience. I still have plenty to improve (as can be observed from feedback in this thread) and I look forward to writing many more books. One simple advice I can give you is start maintaining notes for the tool you are interested in. May be blog post or a repo, that way you can share with others and get feedback. Keep adding one command at a time and in a few months you'll have plenty to write about. Good luck! [1] https://github.com/learnbyexample https://github.com/learnbyexample
- chris_wot 7y agoI purchased it for a guy I know who is new to Unix overall. I spent some money (not a lot, sorry).
- etaioinshrdlu 7y agoFor fun casual reading, try comparing the source code of any BSD utility vs. GNU. BSD tail: https://searchcode.com/codesearch/view/457515/ https://searchcode.com/codesearch/view/457515/ GNU tail: https://github.com/coreutils/coreutils/blob/master/src/tail.c https://github.com/coreutils/coreutils/blob/master/src/tail.... Usually the BSD one is short and sweet and the GNU one is a bit complex. GNU utilities may be high performance but they tend to be hard to understand.
- acuozzo 7y ago> but they tend to be hard to understand It's not just about performance. It's also about portability. GNU utilities are intended to work on various nixen rather than just GNU/Linux. I mean, hell, the GNU tail you link to includes an explicit workaround for odd select() behavior on AIX.
- rambojazz 7y agoIf one writes about free software, using only free tools and free documentation, I'm disappointed when I see that the end product is not free. Just saying.
- asicsp 7y agomaybe others could afford to do so, right now books are my main source of income and I am still burning through my savings also, do you mean that one shouldn't make money by using free software which gives the freedom to make money?
- rambojazz 7y agoNo absolutely not. I wasn't talking of money, I was talking of free license. You used software released with a free license, and documentation available with a free license, to write about software released with a free license, but your end product is a work without a free license. All I'm saying is that you took all the benefits that come with free licenses, but didn't contribute back with a free licensed work. You can do that of course, and again I'm not talking about money. It's just disappointing in a sense.
- asicsp 7y agoSorry, we'll have to agree to disagree, and money does play a huge role when your living depends on what you create. The free resource gives you freedom to choose but you are disappointed when people do so, then what is the point of the free license you talk about? Programming languages like Python and Ruby are also free software that come with documentation. Should books written for those languages also come with free license?
- rambojazz 7y agoI don't understand why you are so defensive. I repeat myself: I'm not talking about money, you can sell for how much you want and I never suggested that you should work for free. It's almost like you're not reading what I'm writing. Anyway, it sounds like you have a very opportunistic idea of what is a free license, like "what it matters to me is only that I can use this material without paying". You are entitled to that, I said this in my prev comment as well. What is disappointing is the thought that somebody would consider these free resources as something merely to be exploited at no cost. If somebody has worked to prepare a free buffet you don't just take everything for yourself because it's free anyway, then tell to the other people that they have no reason to complain because you did nothing wrong. You can, but what kind of person does that? I don't know if this is the best example, but that's the feeling.
- otterpro 7y agoI just finished reading the book, and I found it very helpful especially for beginner grep/ripgrep users. Thank you for making it available. I love the Exercise section. Are there plan on making the solutions to the exercise available? I'm stuck on this question: Ripgrep a) For sample.md input file, match all lines containing ruby irrespective of case, but not if it is part of code blocks that are bounded by triple backticks.
- asicsp 7y agoThanks for the wonderful feedback, makes me happy :) I'd prefer to help readers with hints rather than making solutions public. Give it your best shot and if you are stuck with no where to go, you can contact me via email/twitter mentioned in Preface chapter. Hint for this question: there are multiple possible solutions. I used -P option for its skipping feature (see 'Perl Compatible Regular Expressions' chapter) to avoid the code blocks.