Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Grep
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Implementations== A variety of grep implementations are available in many operating systems and software development environments.<ref>{{cite tech report |first=Tony |last=Abou-Assaleh |author2=Wei Ai|title=Survey of Global Regular Expression Print (GREP) Tools |institution=Dalhousie University|date=March 2004}}</ref> Early variants included egrep and fgrep, introduced in [[Version 7 Unix]].{{r|reader}} The egrep variant supports an [[Regular expression#POSIX basic and extended|extended regular expression]] syntax added by [[Alfred Aho]] after [[Ken Thompson]]'s original regular expression implementation.<ref name=Huma1988>{{cite journal|last1=Hume|first1=Andrew|title=A Tale of Two Greps|journal=Software: Practice and Experience|date=1988|volume=18|issue=11|page=1063|doi=10.1002/spe.4380181105|s2cid=6395770}}</ref> The "fgrep" variant searches for any of a list of ''fixed'' strings using the [[Aho–Corasick string matching algorithm]].<ref name=Meurant1990>{{cite book|last1=Meurant|first1=Gerard|title=Algorithms and Complexity|date=12 Sep 1990|publisher=Elsevier Science|page=278|isbn=9780080933917|url=https://books.google.com/books?id=6WriBQAAQBAJ|access-date=12 December 2015|url-status=live|archive-url=https://web.archive.org/web/20160304084311/https://books.google.com/books?id=6WriBQAAQBAJ&printsec=frontcover&source=gbs_ge_summary_r&cad=0|archive-date=4 March 2016}}</ref> Binaries of these variants exist in modern systems, usually linking to grep or calling grep as a shell script with the appropriate flag added, e.g. <code>exec grep -E "$@"</code>. egrep and fgrep, while commonly deployed on POSIX systems, to the point the POSIX specification mentions their widespread existence, are actually not part of POSIX.<ref>{{cite web|title=grep|url=http://pubs.opengroup.org/onlinepubs/009695399/utilities/grep.html|website=www.pubs.opengroup.org|publisher=The Open Group|access-date=12 December 2015|url-status=live|archive-url=https://web.archive.org/web/20151128184349/http://pubs.opengroup.org/onlinepubs/009695399/utilities/grep.html|archive-date=28 November 2015}}</ref> Other commands contain the word "grep" to indicate they are search tools, typically ones that rely on regular expression matches. The [[pgrep]] utility, for instance, displays the processes whose names match a given regular expression.<ref>{{cite web|title=pgrep(1)|url=http://linux.die.net/man/1/pgrep|website=www.linux.die.net|access-date=12 December 2015|url-status=live|archive-url=https://web.archive.org/web/20151222084135/http://linux.die.net/man/1/pgrep|archive-date=22 December 2015}}</ref> In the [[Perl]] programming language, <code>grep</code> is a built-in function that finds elements in a list that satisfy a certain property.<ref>{{cite web|title=grep|url=http://perldoc.perl.org/functions/grep.html|website=www.perldoc.perl.org|access-date=12 December 2015|url-status=live|archive-url=https://web.archive.org/web/20151207062445/http://perldoc.perl.org/functions/grep.html|archive-date=7 December 2015}}</ref> This [[higher-order function]] is typically named <code>[[filter (higher-order function)|filter]]</code> or <code>where</code> in other languages. {{anchor|pcregrep}}The pcregrep command is an implementation of grep that uses [[Regular expression#Perl and PCRE|Perl regular expression]] syntax.<ref>{{cite web|title=pcregrep man page|url=http://www.pcre.org/original/doc/html/pcregrep.html|website=www.pcre.org|publisher=University of Cambridge|access-date=12 December 2015|url-status=live|archive-url=https://web.archive.org/web/20151223035259/http://www.pcre.org/original/doc/html/pcregrep.html|archive-date=23 December 2015}}</ref> Similar functionality can be invoked in the GNU version of grep with the <code>-P</code> flag.<ref>{{cite web|title=grep(1)|url=http://linux.die.net/man/1/grep|website=www.linux.die.net|access-date=12 December 2015|url-status=live|archive-url=https://web.archive.org/web/20151210004321/http://linux.die.net/man/1/grep|archive-date=10 December 2015}}</ref> [[Porting|Ports]] of grep (within [[Cygwin]] and [[GnuWin32]], for example) also run under [[Microsoft Windows]]. Some versions of Windows feature the similar qgrep or [[findstr]] command.<ref>{{cite book | last = Spalding | first = George | title = Windows 2000 administration | url = https://archive.org/details/windows2000admin0000spal | url-access = registration | access-date = 2010-12-10 | series = Network professional's library | year = 2000 | publisher = Osborne/McGraw-Hill | isbn = 978-0-07-882582-8 | pages = [https://archive.org/details/windows2000admin0000spal/page/634 634] | quote = QGREP.EXE[:] A similar tool to grep in UNIX, this tool can be used to search for a text string }}</ref> A grep command is also part of [[ASCII Corporation|ASCII]]'s ''MSX-DOS2 Tools'' for [[MSX-DOS]] version 2.<ref>{{cite web| url = https://archive.org/details/MSXDOS2TOOLS| title = MSX-DOS2 Tools User's Manual by ASCII Corporation| date = April 1993}}</ref> The grep, egrep, and fgrep commands have also been ported to the [[IBM i]] operating system.<ref>{{cite web |title=IBM System i Version 7.2 Programming Qshell |language=en |author=IBM |website=[[IBM]] |author-link=IBM |url=https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_74/rzahz/rzahzpdf.pdf?view=kc |access-date=2020-09-05 }}</ref> The software [[Adobe InDesign]] has functions GREP (since CS3 version (2007)<ref>{{cite web|url=https://creativepro.com/review-adobe-indesign-cs3/|title=Review: Adobe InDesign CS3 - CreativePro.com|date=20 April 2007|website=creativepro.com|access-date=24 April 2018|url-status=live|archive-url=https://web.archive.org/web/20180105233709/https://creativepro.com/review-adobe-indesign-cs3/|archive-date=5 January 2018}}</ref>), in the ''find/change'' dialog box<ref>{{cite web|title=InDesign Help: find/change|url=https://helpx.adobe.com/indesign/using/find-change.html|access-date=2016-08-12|url-status=live|archive-url=https://web.archive.org/web/20160828124223/https://helpx.adobe.com/indesign/using/find-change.html|archive-date=2016-08-28}}</ref> "GREP" tab, and introduced with InDesign CS4<ref>{{cite web |url=http://carijansen.com/tip-088/ |title=InDesign: GREP Styles (1) Setting text between parentheses in Italic |access-date=2018-01-05 |url-status=live |archive-url=https://web.archive.org/web/20170924230421/http://carijansen.com/tip-088/ |archive-date=2017-09-24 }}</ref> in ''paragraph styles''<ref>{{cite web|title=InDesign Help: GREP styles|url=https://helpx.adobe.com/indesign/using/drop-caps-nested-styles.html#create_grep_styles|access-date=2016-08-12|url-status=live|archive-url=https://web.archive.org/web/20160828114627/https://helpx.adobe.com/indesign/using/drop-caps-nested-styles.html#create_grep_styles|archive-date=2016-08-28}}</ref> "GREP styles". ===agrep=== {{main|agrep}} '''agrep''' (approximate grep) is an [[open-source software|open-source]] [[approximate string matching]] program, developed by [[Udi Manber]] and Sun Wu between 1988 and 1991,<ref>{{cite conference |title=Agrep -- a fast approximate pattern-matching tool |last1=Wu |first1=Sun |last2=Manber |first2=Udi |date=20–24 January 1992 |location=San Francisco, California |conference=1992 Winter USENIX Conference |citeseerx = 10.1.1.89.5424}}</ref> for use with the [[Unix]] operating system. It was later ported to [[OS/2]], [[DOS]], and [[Microsoft Windows|Windows]]. ''a''grep matches even when the text only ''approximately'' fits the search pattern.<ref name=eGrep.SunX>{{cite magazine |magazine=Sun Expert|author=S. Lee Henry |date=June 1998 |pages=35–26|title=Proper Searching}}</ref> This following invocation finds <code>netmasks</code> in file <code>myfile</code>, but also any other word that can be derived from it, given no more than two substitutions. <pre>agrep -2 netmasks myfile</pre> This example generates a list of matches with the closest, that is those with the fewest, substitutions listed first. The command flag <code>-B</code> means "best": <pre>agrep -B netmasks myfile</pre>
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Grep
(section)
Add topic