Jump to content

Talk:grep

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia


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)[reply]

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)[reply]
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)[reply]
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)[reply]

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)[reply]
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)[reply]
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)[reply]
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)[reply]
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)[reply]
much better...203.214.80.107 (talk) 13:53, 30 September 2009 (UTC)[reply]

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)[reply]
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)[reply]

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)[reply]

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)[reply]

Seconded. --maru (talk) contribs 05:07, 12 May 2006 (UTC)[reply]
It's been about four days, so i've removed it. --Piet Delport 02:38, 15 May 2006 (UTC)[reply]
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)[reply]

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)[reply]
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)[reply]
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)[reply]
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)[reply]
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)[reply]

[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)[reply]

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)[reply]

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)[reply]

History Section

[edit]

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

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)[reply]

This goes into the early history of many UNIX commands, including grep, sed, and others. It would be good to include some on Wikipedia: http://www.columbia.edu/~rh120/ch106.x09 Family Guy Guy (talk) 13:19, 27 August 2023 (UTC)[reply]

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)[reply]

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)[reply]

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)[reply]

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)[reply]

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

Syntax

[edit]

This would be a lot easier to understand if the article explained the syntax of the command. How do you set the target/scope of a grep search? Stub Mandrel (talk) 07:02, 27 August 2018 (UTC)[reply]

[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)[reply]

History

[edit]

This contradicts what is currently in the History section of the article, but take a look at Brian Kernighan and Ken Thompson. A nerdy delight for any Vintage Computer Fest 2019 attendee: Kernighan interviewing Thompson about Unix. YouTube. Event occurs at 35m40s to 38m32s. Retrieved September 3, 2019. It seems as if this should be covered in the article. Wtmitchell Wtmitchell (talk) (earlier Boracay Bill) 16:00, 3 September 2019 (UTC)[reply]

Now the history section manages to contradict itself, stating two incompatible origin stories as fact without comment.--71.163.110.245 (talk) 15:45, 2 November 2019 (UTC)[reply]
In this (cited in support of the second story) Kernighan asserts that grep was written overnight (as mentioned in the first story, but asserted as fact -- the first story is 36m30s into this) by Thompson in response to a request from McMahon (from the second story). Perhaps it would be better, if wordier, to write something like "according to [source], ..." rather than stating assertions as facts. Yes, the stories contradict -- it was a long time ago, even if it does seem like yesterday to those who were involved. Wtmitchell (talk) (earlier Boracay Bill) 17:48, 2 November 2019 (UTC)[reply]

But what formats can it find?

[edit]

A lot of search tools fail to find certain file formats, or ignore hits after a certain point in the file, or fail to find non-Roman text in certain file formats. So a list of what formats grep can find would be relevant and useful. 108.51.205.136 (talk) 19:49, 21 December 2019 (UTC)[reply]

Brian Kernighan wrote grep?

[edit]

In the most recent Computerphile video on YouTube, titled "Coffee with Brian Kernighan", at the very end, Brailsford asks "Who wrote grep?" and Kernighan points at himself, saying "I did".

I always thought Thompson wrote it, but Kernighan really isn't the type to take accomplishments from Thompson, he always shows massive admiration for Thompson. So I am a bit confused. Kernighan saying he wrote it, is as much as a first-hand source as we ever get to. How to proceed?--91.64.59.136 (talk) 13:16, 28 August 2022 (UTC)[reply]