Linked by Thom Holwerda on Sat 10th Jan 2015 00:38 UTC
General Unix

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.

Order by: Score:
Comment by Gone fishing
by Gone fishing on Sat 10th Jan 2015 02:27 UTC
Gone fishing
Member since:
2006-02-22

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!

Reply Score: 6

RE: Comment by Gone fishing
by leech on Sat 10th Jan 2015 02:57 UTC in reply to "Comment by Gone fishing"
leech Member since:
2006-01-10

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

Reply Score: 5

RE[2]: Comment by Gone fishing
by Drumhellar on Sat 10th Jan 2015 04:20 UTC in reply to "RE: Comment by Gone fishing"
Drumhellar Member since:
2005-07-12

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?


Well, technically, that was a real thing.

http://en.wikipedia.org/wiki/Fsn

Reply Score: 5

RE[2]: Comment by Gone fishing
by kwan_e on Sat 10th Jan 2015 13:15 UTC in reply to "RE: Comment by Gone fishing"
kwan_e Member since:
2007-02-18

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.."


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

Reply Score: 5

RE[3]: Comment by Gone fishing
by dylansmrjones on Sat 10th Jan 2015 16:10 UTC in reply to "RE[2]: Comment by Gone fishing"
dylansmrjones Member since:
2005-10-02

rm -rf /

That would have spoiled the entire plot of the movies.

Reply Score: 5

RE[2]: Comment by Gone fishing
by ConceptJunkie on Sat 10th Jan 2015 21:03 UTC in reply to "RE: Comment by Gone fishing"
ConceptJunkie Member since:
2012-05-18

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.

Reply Score: 2

agrep history?
by ioconnor on Sat 10th Jan 2015 03:35 UTC
ioconnor
Member since:
2013-02-02

I find agrep incredibly useful. Yet never see much talk about it. Any reason for that?

Reply Score: 2

RE: agrep history?
by Nth_Man on Sat 10th Jan 2015 17:01 UTC in reply to "agrep history?"
Nth_Man Member since:
2010-05-16

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...

Reply Score: 2

RE: agrep history?
by krakal on Sat 10th Jan 2015 17:04 UTC in reply to "agrep history?"
krakal Member since:
2015-01-03

I find agrep incredibly useful. Yet never see much talk about it. Any reason for that?


Because grep is used by developers to find exact matches. For fuzzy searching, most people use fzf.

Reply Score: 1

RE[2]: agrep history?
by agentj on Sun 11th Jan 2015 07:26 UTC in reply to "RE: agrep history?"
agentj Member since:
2005-08-19

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

Reply Score: 2

RE[2]: agrep history?
by jgagnon on Mon 12th Jan 2015 14:48 UTC in reply to "RE: agrep history?"
jgagnon Member since:
2008-06-24

What is fzf? It's not showing up anywhere in the Mint 17.1 KDE repository.

Reply Score: 2

Yeah
by krakal on Sat 10th Jan 2015 11:45 UTC
krakal
Member since:
2015-01-03

So Ken is a friggin' genius. What else is new.

Reply Score: 2

Comment by ssokolow
by ssokolow on Sat 10th Jan 2015 12:25 UTC
ssokolow
Member since:
2010-01-21

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.

Reply Score: 3

RE: Comment by ssokolow
by kwan_e on Sat 10th Jan 2015 13:06 UTC in reply to "Comment by ssokolow"
kwan_e Member since:
2007-02-18

But those, and many other desired options, can be scripted.

Reply Score: 3

Comment by defdog99
by defdog99 on Sat 10th Jan 2015 18:47 UTC
defdog99
Member since:
2006-09-06

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.

Reply Score: 2

Silver Searcher
by vivainio on Sat 10th Jan 2015 21:08 UTC
vivainio
Member since:
2008-12-26

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")

Reply Score: 3

Code search
by acobar on Sun 11th Jan 2015 10:04 UTC
acobar
Member since:
2005-11-15

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).

Reply Score: 3