grep is a Unix command line utility (well most Unix utilities are command line) that searches the input files for pattern and prints lines that contain the pattern. If you are reading this you, you are probably no stranger to grep.
grep was written by Ken Thompson, the same guy who wrote Unix. grep first appeared in Unix v4 with limited features as compared to today’s grep.
I’ve used grep so much over the years. One of the countless little utilities that’s the staple of all UNIX-like systems that you never really think about, but use all the time.
Damn useful too, It’s commands like greb that won me over to the Linux world and “the power of the commanlineâ€, I just wish I was a bit better at using all these great little tools.
Google is still my friend!
I use grep on probably an hourly basis, if not more frequently. I mean who wants to muddle through all of the other lines, when you know what you’re looking for.
In fact, I bust out laughing recently when I was watching Jurassic Park, and Samuel L Jackson was in it and said that “we’d have to go through each line of code the password, and there are over a million lines.” or something like that. “why don’t you just grep for some strings dude.. it’ll take a few minutes max..”
Then again, I think there is also a part in that where the little girl says ‘oh these are Unix systems, I know how to use these’ and there was this fully graphical 3D map she was using to find information…
https://www.youtube.com/watch?v=URVS4H7vrdU
Oh good god, now I remember this a real thing.. Ha. grep-3d?
Edited 2015-01-10 03:01 UTC
Well, technically, that was a real thing.
http://en.wikipedia.org/wiki/Fsn
Unless he knew what strings the code contained that would single it out in contrast to unrelated code, it wouldn’t help. grep is good, but you still need to know what to find.
—————-
On another note, they should have designed the park around the UNIX philosophy of every being a file. Then they could have just:
“rm /proc/velociraptor_id/*”
Edited 2015-01-10 13:15 UTC
rm -rf /
That would have spoiled the entire plot of the movies.
Yeah, I search millions of lines of code on a daily basis. Although I use the regex search function of my editor (Multi-edit), it’s the same functionality as grep.
I find agrep incredibly useful. Yet never see much talk about it. Any reason for that?
Yes, it’s handy sometimes, although it’s not widely known.
The program “agrep” has a too restrictive license, so in Kubuntu I found it in the “multiverse” packages:
http://changelogs.ubuntu.com/changelogs/pool/multiverse/a/agrep/agr…
but the program “tre-agrep” has a license which has no problems with its use “for profit”, so in Kubuntu I found it in the “universe” packages:
http://changelogs.ubuntu.com/changelogs/pool/universe/t/tre/tre_0.8…
There are some examples of tre-agrep in:
http://linuxaria.com/howto/linux-terminal-how-to-do-fuzzy-search-wi…
Because grep is used by developers to find exact matches. For fuzzy searching, most people use fzf.
Yes, using grep (and other unix tools) consists of 99% of programmer’s work. Recently I spend so much time using grep that I don’t have chance to do anything else … Nah, I just prefer Ctrl+Left Click or F2/F3 and real code completion.
Edited 2015-01-11 07:27 UTC
What is fzf? It’s not showing up anywhere in the Mint 17.1 KDE repository.
So Ken is a friggin’ genius. What else is new.
I use grep a lot but, as a programmer, I probably use ack (ack-grep on Debian) more.
http://beyondgrep.com/
Ignoring directories like .svn and .git by default, limiting to an easily extended list of known filetypes, and having easy by-type filtering presets (which map one name to one or more extensions) really saves thought and time.
But those, and many other desired options, can be scripted.
Regular Grep takes wildcards…So you can be fuzzy with those.
I’ll tell you the biggest boon was when someone added -r for recursive directory searching. Older unixes had to use find / -exec grep {} /dev/null \; combos. So much easier now-a-days.
I use “Silver Searcher”:
https://github.com/ggreer/the_silver_searcher
A bit like ack-grep, but faster and no perl
(available also on Windows, “choco install ag”)
I like grep but for source code search/browsing there are way better tools like cscope, pyscope, starscope, ctags, cxxtags, opengrok and codequery. Vim, Emacs and some code editors have their functionalities integrated (mostly by plugins).