Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comments for Using Awk to beautify grep searches #1282

Open
phinjensen opened this issue Nov 11, 2017 · 8 comments
Open

Comments for Using Awk to beautify grep searches #1282

phinjensen opened this issue Nov 11, 2017 · 8 comments

Comments

@phinjensen
Copy link
Contributor

phinjensen commented Nov 11, 2017

Comments for https://www.endpointdev.com/blog/2017/01/using-awk-to-beautify-grep-searches/
By Kamil Ciemniewski

To enter a comment:

  1. Log in to GitHub
  2. Leave a comment on this issue.
@phinjensen
Copy link
Contributor Author

original author: Andrew Gallant
date: 2017-01-19T11:17:26-05:00

ripgrep author here.

Note that this blog post contains some false information and some misconceptions.

First and foremost, you absolutely do not need a Rust compiler to use ripgrep. You don't need to install Rust at all, in fact. As the README for ripgrep says, you can download binary releases of ripgrep for Linux, Mac or Windows. (There are no binaries available for FreeBSD, on which you would need to compile ripgrep.)

Secondly, I didn't set out to write ripgrep because "oooo new and shiny." That's a pretty dramatic underselling of my motivation and the work I put into it. I set out to write it because I cared about all the same things you did: presentation, retrieval, and of course, improving the state of the art. It wasn't about shaving off a few hundred milliseconds here and there. It was about turning searches that take minutes with ack or grep into seconds. You can see benchmarks for such things on my blog post introducing ripgrep.

Thirdly, tools like ripgrep and ag advertise a key feature that you've left out here: they respect your .gitignore files. While this isn't always desirable, it turns out that a lot of people find this to be an excellent default when searching source code repositories. A lot of people would cite this as a key missing feature from your approach.

Believe it or not, the developers of these tools weren't ignorant of tools like GNU grep. We learned from it and set out to try to improve it. I think we've succeeded.

Will some people not need the improvements? Of course! But let's just be honest about that instead of waxing poetic about how old software is Good and new and shiny software is Bad.

@phinjensen
Copy link
Contributor Author

original author: Kamil Ciemniewski
date: 2017-01-19T14:36:03-05:00

Andrew,

I might not have been clear enough in the blog post about how much respect I have for the work you and other authors of similar projects have done! It's clear to me, that the tools you built have their place and in many cases are invaluable. I can imagine code repositories so big that - like you pointed out - take minutes to search through.

My point isn't that we don't need projects like yours. It's that in most cases the needs we have are already covered and that we might not know about it. That was my humble case. I was using ripgrep myself and was very happy with it. I didn't know much about using awk not too long ago and the blog post arose from me learning how to get the similar looking results with the tools I always had. I just realized that I didn't know a lot of what Unix gives us and that for the most part - it is just enough.

I strongly encourage everyone reading this conversation to:

  1. Take the time to explore and learn these "old" programs, languages etc. that we have - they are still massively useful
  2. Use whatever new tools you like that are superior for the task at hand whenever you really have a need

P.S
Thank you for the link to the binary releases.

@phinjensen
Copy link
Contributor Author

original author: Andrew Gallant
date: 2017-01-19T16:39:45-05:00

Kamil,

That's fair. I definitely agree with everything you've said here. As the author of one of those tools, I totally admit to being a bit sensitive to the "new and shiny" criticism, because it just seems a bit too dismissive to me. We should seek to improve upon old tools, and if the only thing standing in your way of using them is accessibility, then we should make them more accessible. :-) That's a long and hard fight though!

  • Andrew

@phinjensen
Copy link
Contributor Author

original author: Richard Michael
date: 2017-01-19T23:52:36-05:00

You may be interested in sgrep:

https://www.cs.helsinki.fi/u/jjaakkol/sgrepman.html
https://www.cs.helsinki.fi/u/jjaakkol/sgrep/

At some point, it was included in either RedHat or perhaps Fedora later, but no longer. Perhaps it could still be built from an older SRPM.

@phinjensen
Copy link
Contributor Author

original author: Kamil Ciemniewski
date: 2017-01-20T03:27:26-05:00

Hi Richard, sgrep looks very interesting - I can see that it is in MacPorts - Thank you for sharing!

@phinjensen
Copy link
Contributor Author

original author: David Christensen
date: 2017-01-20T10:26:55-05:00

As 99% of what I use projects for is in git, I tend to use git grep fairly extensively which is very fast. I haven't tested many other options, but may do so; thanks guys for info about the new tools.

@stephenstack
Copy link

This script saved my bacon! :) Thank you for the detailed explanation and the script. I did have an issue when using A, B, C switches with grep to display lines, before and after, and the : between filename and line numebr was a dash. Example below.

filename-112:string
filename-112:string
filename:112:matchingstring
filename:112:matchingstring
filename-112:string

I was not able to make sense of your 'sed' comment in the final paragraph in the post, but I did use regex in the FS to check for either : or -. Works! 👍

FS="[:-]"

Thanks

@Bhupesh-V
Copy link

This was a lifesaver, thanks for writing this 🔥
Also here is an additional tip if someone reads this, grep also has a --exclude-dir option to ignore certain directories

grep -nir --color=always --exclude-dir={_site,.git,.github,node_modules}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants