Talk:Grep

From Wikipedia, the free encyclopedia
Jump to: navigation, search
WikiProject Computing (Rated Start-class, Low-importance)
WikiProject icon This article is within the scope of WikiProject Computing, a collaborative effort to improve the coverage of computers, computing, and information technology on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
Start-Class article Start  This article has been rated as Start-Class on the project's quality scale.
 Low  This article has been rated as Low-importance on the project's importance scale.
 
WikiProject Computer science (Rated Start-class, Low-importance)
WikiProject icon This article is within the scope of WikiProject Computer science, a collaborative effort to improve the coverage of Computer science related articles on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
Start-Class article Start  This article has been rated as Start-Class on the project's quality scale.
 Low  This article has been rated as Low-importance on the project's importance scale.
 

Find[edit]

The recently added section about ms-dos find dosn't belong to this page IMHO. If no one complains I will remove it. Lost Goblin 02:18, 14 May 2005 (UTC)

I agree. It would set a bad precedent too, to start littering every software-related article with "here's a discussion of other software". TreyHarris 04:26, 14 May 2005 (UTC)
Ok, I removed it then. Lost Goblin 09:21, 2005 May 14 (UTC)
It (or a variation thereof) seems to have crept back in. I was going to remove it after seeing this discussion, but it's listed alongside GNU grep with Cygwin as one of the available options for text file search functionality on Windows. Wthrower (talk) 23:44, 9 July 2008 (UTC)
being that cygwin is about 99% posix compliant and the link has genuine relevance probably best left alone.124.171.210.147 (talk) 13:24, 11 September 2009 (UTC)

Asterisk versus period[edit]

'grep -r foo .' seems more appropriate than 'grep -r foo *'. The former is literally recursively searching the current directory, while the latter is only searching the non-hidden files and directories in the current directory, and their (hidden or non-hidden) subdirectories/files. (meaning it's inconsistent, only ignoring hidden stuff in the current directory, but showing all other hidden stuff below it) —Preceding unsigned comment added by 216.99.35.21 (talkcontribs) 03:10, 7 June 2005

-r is a gnu-ism and should probably be removed anyway, proper way to do is using find and `` or xargs instead. Lost Goblin 19:39, 2005 May 30 (UTC)

Usage information[edit]

Although I'm not asking to make this Wikipedia article into a man page, a few more examples of how to use grep would be nice. Partly because less technical users have trouble understanding man pages, and therefore they could benefit from explanation here. —Preceding unsigned comment added by 216.99.35.21 (talkcontribs) 03:10, 7 June 2005

I agree, I think this page should have more information. —Preceding unsigned comment added by 70.64.188.255 (talkcontribs) 04:26, 28 September 2005
I've noticed that some good information has been removed because it is non-standard as per the opengroup spec. Is it really necessary to only include standard options in this article if every major implementation supports options such as -r, -o and -d ? It's my opinion that we should add some more information to help those hoping to use this article as a topical guide. IncidentalPoint (talk) 20:03, 2 September 2008 (UTC)
See WP:USEFUL. It is highly unlikely that anyone will go to Wikipedia before a man page, so filling an article which is meant to be descriptive with technical junk about switches is inappropriate. Chris Cunningham (not at work) - talk 09:39, 4 September 2008 (UTC)
How is it inappropriate, if people come here after looking at man, info, --help and still are unable to find the info they need I fail to see how it is inappropriate. It's the exact reason I jumped on wikki, there are not even links to regular expressions when mentioning regular expressions. At very LEAST there should be links for that imo. EDIT: typo relevant=regular 124.171.210.147 (talk) 13:30, 11 September 2009 (UTC)
PS. the link you defined WP:USEFUL. to take a line straight from it: There are some times when "usefulness" can be the basis of a valid argument for inclusion. An encyclopedia should, by definition, be informative and useful to its readers. Try to exercise common sense, and consider how a non-trivial number of people will consider the information "useful". 124.171.210.147 (talk) 13:36, 11 September 2009 (UTC)
pearl-regular-expression syntax is a direct link to http://en.wikipedia.org/wiki/Regular_expression[1], which I didn't realize before posting the above posts. I still think a link when referencing "regular expression" should be included. As the point on pcregrep- perl regular expression would not be what most people are looking for unless scripting in perl rather than scripting posix compliant shell.124.171.210.147 (talk) 08:50, 12 September 2009 (UTC)
much better...203.214.80.107 (talk) 13:53, 30 September 2009 (UTC)

abbreviation[edit]

according to Jeffrey Friedl's Mastering Regular Expressions 2nd Ed (O'Reilly 2002) grep stands simply for global regular expression print.

—Preceding unsigned comment added by 80.108.115.184 (talkcontribs) 01:13, 13 October 2005

Going back even further, it is listed as Global Regular Expression Print in Dale Dougherty's sed & awk (O'Reilly 1990). The assertion that this is a backronym is tenuous. Since when would any Unix user state "search globally for lines matching the regular expression, and print them" when "Global Regular Expression Print" says it all? --59.167.194.142 06:06, 16 November 2006 (UTC)
Common Unix commands are rarely acronyms, and this one is so tortured that it's obvious that this was retroactively formed. There's a reason a certain company's books are commonly mocked by the name O RLY. Chris Cunningham (not at work) - talk 10:40, 10 July 2008 (UTC)

So I'm going to cancel the "goto" recently placed:

  1. Global 231 000
  2. General 9 300
  3. Get 93
  4. Goto 1: here

JackPotte (talk) 14:45, 24 April 2010 (UTC)

Conversational usage as verb[edit]

I agree with the comment on the history page requesting citation: if "grep" is ever used with the meaning of "grok", it is simply an error by the ignorant. I don't think that this is an established usage. I think that this claim should be deleted unless someone can provide evidence that there is a community in which this usage is normal. --Bill 20:50, 11 May 2006 (UTC)

Seconded. --maru (talk) contribs 05:07, 12 May 2006 (UTC)
It's been about four days, so i've removed it. --Piet Delport 02:38, 15 May 2006 (UTC)
I have conversationally used grep in a non technical sense (as in grepping one's mind). Of course, that use was a bit of silliness on my part since I certainly don't have the ability to do a full fledged search of any concepts of any symbolic nature my mind might hold. Root4(one) 04:35, 28 March 2007 (UTC)

Meaning of name[edit]

When I first came across grep on a Prime Minicomputer in 1986 it was noted as General-Purpose Random Expresion Parser. It was in an American published user guide. I may still have a copy of it somewhere and will try to check it out. —Preceding unsigned comment added by 193.113.57.167 (talkcontribs) 2006-09-16 01:59:42

It also looks suspiciously close to a Dutch verb for 'to understand', begrepen. —Preceding unsigned comment added by 66.202.2.241 (talkcontribs) 2006-09-16 01:59:42
Read the Jargon file entry which cites the author of the tool specifically confirming that the origin is the ed command g/re/p and not any of the other anecdotal sources. Many companies and people may have ascribed backronyms, but we need to be very clear about the original source of the name, and how it was meant to expand. -Harmil 15:33, 24 July 2007 (UTC)
Exactly. The author of the tool is the best source for its name, so this should come back out. Adding a disputed backronym to the intro is misleading. Chris Cunningham (not at work) - talk 10:41, 10 July 2008 (UTC)
I'm removing this again. The author of the tool is evidently a more reliable source than an O RLY. Chris Cunningham (not at work) - talk 10:08, 22 July 2008 (UTC)
What, exactly do you think that the ed command g/re/p stands for? Global / RegEx / Print. Jim no.6 (talk) 17:15, 10 August 2010 (UTC)
There was a revision back to "parser", so I figured a few more sources might be fun :-). First, let's establish the link between grep and ed. From the UNIX Version 6 manual page for grep at http://man.cat-v.org/unix-6th/1/grep :
For a complete description of the regular expression, see ed
     (I).  Care should be taken when using ...

Early sources show nothing about "parser", only "print". From Version 6 UNIX manual page for the ed editor, http://man.cat-v.org/unix-6th/1/ed, we see that the g command is "global":

      (1,$)g/regular expression/command list
          In the global command, the first step is to mark every
          line which matches the given regular expression.  Then
          for every such line, the given command list is executed
          with `.' initially set to that line.  A single command
          or the first of multiple commands appears on the same
          line with the global command.  ...


Also regular expression is clearly there too. For the command list suffix, we are using a single p command . The p command is documented as print

     ( . , . )p
          The print command prints the addressed lines.  `.'  is
          left at the last line printed.  The p command may be
          placed on the same line after any command.
     

And just to be more complete, lets look back to the V4 UNIX manual page for grep from March 3rd, 1973 http://minnie.tuhs.org/cgi-bin/utree.pl?file=V4/man/man1/grep.1 . Here, if we search for SPACE and p, (" p"), we find 7 occurrences: the first is "pattern", which refers to the regular express. The remaining six are the word "printed". No mention is made for "parser".

So let's go to the source code: ftp://ftp.math.utah.edu/pub//mirrors/minnie.tuhs.org/PDP-11/Distributions/research/Dennis_v6/ and the GZIP'd TAR archive : ftp://ftp.math.utah.edu/pub//mirrors/minnie.tuhs.org/PDP-11/Distributions/research/Dennis_v6/v6src.tar.gz and down in the s1 (for Section 1) subdirectory, we find grep.c in refreshingly old C :-) . The sole comment in the program is right in the first lines of the file and is:

#
/*
 * grep -- print lines matching (or not matching) a pattern
 *
 */

#define CCHR    2
#define CDOT    4

Nowhere in the file is the word parse mentioned :-) (and I can't pass without showing the ancient C =+ rather than += )

   case CCL:
                if (cclass(ep, *lp++, 1)) {
                        ep =+ *ep;
                        continue;
                }
                return(0);

So ultimately, the original meaning from 1973 should trump some technical writer at Prime in 1986 backronyming the name.

--Lent (talk) 17:47, 28 September 2012 (UTC)

External links[edit]

I've removed the link to GNU grep from the extlinks section again. The article already contains a link to "Tony Abou-Assaleh's list of Greps" (unfortunately sub-titled "Global Regular Expression Print Tools"), which links to various different greps. We needn't include an additional link just for GNU grep. Chris Cunningham (not at work) - talk 10:12, 22 July 2008 (UTC)

A good reference?[edit]

I believe this article

http://www.columbia.edu/~rh120/ch001j.c11

About the origin should be referenced in the references and maybe in the ariticle itself.

What do others think?

Hogan (talk) 15:31, 4 February 2009 (UTC)

A blog entry as a reference?[edit]

Just take a look, You Can't Grep Dead Trees. It's currently the fourth reference to this article. I left it intact as I'm not sure whether the link to a casual blog post is proper or not. Protez (talk) 15:56, 16 October 2009 (UTC)

History Section[edit]

Does it need one? —Preceding unsigned comment added by 65.196.214.163 (talk) 14:41, 20 October 2009 (UTC)

The date in the man page for Unix 4 does not necessarily mean the creation date. I emailed Ken Thompson himself who clarified it was his private command for quite a while.208.15.90.2 (talk) 17:12, 14 January 2014 (UTC)

Removing example[edit]

I'm removing the following example, under the assumption that confusing help is worse than no help at all:

To solve this problem, a simple workaround is use grep again with ^ and $:
grep -w apple fruitlist.txt | grep -w ^apple$

1. If you're going to do "grep -w ^apple$" there's no point in the preceding command. Or the -w for that matter. 2. The "$" suffix hasn't been explained yet.

If anyone cares to improve this and reinstate it that would be fine with me. 68.110.104.80 (talk) 02:14, 10 February 2010 (UTC)

Notes[edit]

I am not sure that not no. 5

^ Zaid Alawi. ""You Can't Grep Dead Trees"". Retrieved 2009-06-09.

is relevant here, I think it should be omitted?? —Preceding unsigned comment added by 76.19.135.92 (talk) 14:14, 13 July 2010 (UTC)

As it's a little bit too tutorial to be encyclopaedic, let's move it to b:How_To_Search/grep. JackPotte (talk) 10:23, 16 July 2010 (UTC)

I have added the -v section[edit]

i believed that the article needed how to ignore a search term as well. it just made sense. Foxwolfblood (talk) 02:10, 7 November 2010 (UTC)

Yes, it's important to know that the contrary works too. JackPotte (talk) 03:10, 7 November 2010 (UTC)

Blacklisted Links Found on Grep[edit]

Cyberbot II has detected links on Grep which have been added to the blacklist, either globally or locally. Links tend to be blacklisted because they have a history of being spammed or are highly inappropriate for Wikipedia. The addition will be logged at one of these locations: local or global If you believe the specific link should be exempt from the blacklist, you may request that it is white-listed. Alternatively, you may request that the link is removed from or altered on the blacklist locally or globally. When requesting whitelisting, be sure to supply the link to be whitelisted and wrap the link in nowiki tags. Please do not remove the tag until the issue is resolved. You may set the invisible parameter to "true" whilst requests to white-list are being processed. Should you require any help with this process, please ask at the help desk.

Below is a list of links that were found on the main page:

  • https://www.grepmaster.eu
    Triggered by \bgrepmaster\.eu on the global blacklist

If you would like me to provide more information on the talk page, contact User:Cyberpower678 and ask him to program me with more info.

From your friendly hard working bot.—cyberbot II NotifyOnline 03:26, 17 October 2014 (UTC)