Grep

grep
Original author(s)Ken Thompson[1][2]
Developer(s)AT&T Bell Laboratories
Initial releaseNovember 1973; 51 years ago (1973-11)[1]
Written inC
Operating systemUnix, Unix-like, Plan 9, Inferno, OS-9, MSX-DOS, IBM i
PlatformCross-platform
TypeCommand

grep is a command-line utility for searching plaintext datasets for lines that match a regular expression. Its name comes from the ed command g/re/p (global regular expression search and print), which has the same effect.[3][4] grep was originally developed for the Unix operating system, but later became available for all Unix-like systems and some others such as OS-9.[5]

History

Before it was named, grep was a private utility written by Ken Thompson to search files for certain patterns. Doug McIlroy, unaware of its existence, asked Thompson to write such a program. Responding that he would think about such a utility overnight, Thompson actually corrected bugs and made improvements for about an hour on his own program called s (short for "search"). The next day he presented the program to McIlroy, who said it was exactly what he wanted. Thompson's account may explain the belief that grep was written overnight.[6]

Thompson wrote the first version in PDP-11 assembly language to help Lee E. McMahon analyze the text of The Federalist Papers to determine authorship of the individual papers.[7] The ed text editor (also authored by Thompson) had regular expression support but could not be used to search through such a large amount of text, as it loaded the entire file into memory to enable random access editing, so Thompson excerpted that regexp code into a standalone tool which would instead process arbitrarily long files sequentially without buffering too much into memory.[1] He chose the name because in ed, the command g/re/p would print all lines featuring a specified pattern match.[8][9] grep was first included in Version 4 Unix. Stating that it is "generally cited as the prototypical software tool", McIlroy credited grep with "irrevocably ingraining" Thompson's tools philosophy in Unix.[10]

Implementations

A variety of grep implementations are available in many operating systems and software development environments.[11] Early variants included egrep and fgrep, introduced in Version 7 Unix.[10] The "egrep" variant supports an extended regular expression syntax added by Alfred Aho after Ken Thompson's original regular expression implementation.[12] The "fgrep" variant searches for any of a list of fixed strings using the Aho–Corasick string matching algorithm.[13] 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. exec grep -E "$@". 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.[14]

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.[15]

In the Perl programming language, grep is the name of the built-in function that finds elements in a list that satisfy a certain property.[16] This higher-order function is typically named filter or where in other languages.

The pcregrep command is an implementation of grep that uses Perl regular expression syntax.[17] Similar functionality can be invoked in the GNU version of grep with the -P flag.[18]

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.[19]

A grep command is also part of ASCII's MSX-DOS2 Tools for MSX-DOS version 2.[20]

The grep, egrep, and fgrep commands have also been ported to the IBM i operating system.[21]

The software Adobe InDesign has functions GREP (since CS3 version (2007)[22]), in the find/change dialog box[23] "GREP" tab, and introduced with InDesign CS4[24] in paragraph styles[25] "GREP styles".

agrep

agrep (approximate grep) is an open-source approximate string matching program, developed by Udi Manber and Sun Wu between 1988 and 1991,[26] for use with the Unix operating system. It was later ported to OS/2, DOS, and Windows.

agrep (approximate grep) matches even when the text only approximately fits the search pattern.[27]

This following invocation finds netmasks in file myfile, but also any other word that can be derived from it, given no more than two substitutions.

agrep -2 netmasks myfile

This example generates a list of matches with the closest, that is those with the fewest, substitutions listed first. The command flag B means best:

agrep -B netmasks myfile

Usage as a verb

In December 2003, the Oxford English Dictionary Online added "grep" as both a noun and a verb.[28]

A common verb usage is the phrase "You can't grep dead trees"—meaning one can more easily search through digital media, using tools such as grep, than one could with a hard copy (i.e. one made from "dead trees", which in this context is a dysphemism for paper).[29]

See also

References

  1. ^ a b c Kernighan, Brian (1984). The Unix Programming Environment. Prentice Hall. pp. 102. ISBN 0-13-937681-X.
  2. ^ “grep was a private command of mine for quite a while before i made it public.” -Ken Thompson Archived 2015-05-26 at the Wayback Machine, By Benjamin Rualthanzauva, Published on Feb 5, 2014, Medium
  3. ^ Hauben et al. 1997, Ch. 9
  4. ^ Raymond, Eric. "grep". Jargon File. Archived from the original on 2006-06-17. Retrieved 2006-06-29.
  5. ^ Paul S. Dayan (1992). The OS-9 Guru - 1 : The Facts. Galactic Industrial Limited. ISBN 0-9519228-0-7.
  6. ^ VCF East 2019 -- Brian Kernighan interviews Ken Thompson (video). YouTube. 6 May 2019. Archived from the original on 2021-12-11. (35 mins)
  7. ^ Computerphile, Where GREP Came From, interview with Brian Kernighan
  8. ^ "ed regexes". perl.plover.com. Archived from the original on 20 October 2017. Retrieved 24 April 2018.
  9. ^ "How Grep Got its Name". robots.thoughtbot.com. Archived from the original on 9 August 2017. Retrieved 24 April 2018.
  10. ^ a b McIlroy, M. D. (1987). A Research Unix reader: annotated excerpts from the Programmer's Manual, 1971–1986 (PDF) (Technical report). CSTR. Bell Labs. 139. Archived (PDF) from the original on 2017-11-11.
  11. ^ Abou-Assaleh, Tony; Wei Ai (March 2004). Survey of Global Regular Expression Print (GREP) Tools (Technical report). Dalhousie University.
  12. ^ Hume, Andrew (1988). "A Tale of Two Greps". Software: Practice and Experience. 18 (11): 1063. doi:10.1002/spe.4380181105. S2CID 6395770.
  13. ^ Meurant, Gerard (12 Sep 1990). Algorithms and Complexity. Elsevier Science. p. 278. ISBN 9780080933917. Archived from the original on 4 March 2016. Retrieved 12 December 2015.
  14. ^ "grep". www.pubs.opengroup.org. The Open Group. Archived from the original on 28 November 2015. Retrieved 12 December 2015.
  15. ^ "pgrep(1)". www.linux.die.net. Archived from the original on 22 December 2015. Retrieved 12 December 2015.
  16. ^ "grep". www.perldoc.perl.org. Archived from the original on 7 December 2015. Retrieved 12 December 2015.
  17. ^ "pcregrep man page". www.pcre.org. University of Cambridge. Archived from the original on 23 December 2015. Retrieved 12 December 2015.
  18. ^ "grep(1)". www.linux.die.net. Archived from the original on 10 December 2015. Retrieved 12 December 2015.
  19. ^ Spalding, George (2000). Windows 2000 administration. Network professional's library. Osborne/McGraw-Hill. pp. 634. ISBN 978-0-07-882582-8. Retrieved 2010-12-10. QGREP.EXE[:] A similar tool to grep in UNIX, this tool can be used to search for a text string
  20. ^ "MSX-DOS2 Tools User's Manual by ASCII Corporation". April 1993.
  21. ^ IBM. "IBM System i Version 7.2 Programming Qshell" (PDF). IBM. Retrieved 2020-09-05.
  22. ^ "Review: Adobe InDesign CS3 - CreativePro.com". creativepro.com. 20 April 2007. Archived from the original on 5 January 2018. Retrieved 24 April 2018.
  23. ^ "InDesign Help: find/change". Archived from the original on 2016-08-28. Retrieved 2016-08-12.
  24. ^ "InDesign: GREP Styles (1) Setting text between parentheses in Italic". Archived from the original on 2017-09-24. Retrieved 2018-01-05.
  25. ^ "InDesign Help: GREP styles". Archived from the original on 2016-08-28. Retrieved 2016-08-12.
  26. ^ Wu, Sun; Manber, Udi (20–24 January 1992). Agrep -- a fast approximate pattern-matching tool. 1992 Winter USENIX Conference. San Francisco, California. CiteSeerX 10.1.1.89.5424.
  27. ^ S. Lee Henry (June 1998). "Proper Searching". Sun Expert. pp. 35–26.
  28. ^ "New words list December 2003". Oxford English Dictionary. Retrieved 2021-12-06.
  29. ^ Jargon File, article "Documentation"
Notes
  • Alain Magloire (August 2000). Grep: Searching for a Pattern. Iuniverse Inc. ISBN 0-595-10039-2.
  • Hume, Andrew Grep wars: The strategic search initiative. In Peter Collinson, editor, Proceedings of the EUUG Spring 88 Conference, pages 237–245, Buntingford, UK, 1988. European UNIX User Group.
  • Michael Hauben; et al. (April 1997). Netizens: On the History and Impact of Usenet and the Internet (Perspectives). Wiley-IEEE Computer Society Press. ISBN 978-0-8186-7706-9.

Read other articles:

Mario Agodino Información personalNacimiento 1917 San Francisco (Argentina) Fallecimiento 1975 Nacionalidad ArgentinaInformación profesionalOcupación Abogado y político Cargos ocupados Gobernador de la provincia de Córdoba Partido político Partido Justicialista [editar datos en Wikidata] Mario Dante Agodino (San Francisco, Córdoba, 1917 - 1975) fue un político argentino, integrante del Partido Justicialista, abogado, miembro fundador del Colegio de Abogados de la Quinta Circ...

 

Molly MaloneMalone pada 1921LahirViolet Isabel Malone(1888-12-07)7 Desember 1888Wisconsin, Amerika SerikatMeninggal14 Februari 1952(1952-02-14) (umur 63)Los Angeles, California, Amerika SerikatPekerjaanPemeranTahun aktif1916–1929Suami/istriFrancis CornetWilliam Crothers Violet Elizabeth Malone (nama panggung Molly Malone) (7 Desember 1888 – 14 Februari 1952) adalah seorang pemeran Amerika Serikat pada era film bisu.[1] Ia tampil dalam 86 film antara 1916 da...

 

Лев Юлійович Миримськийрос. Лев Юльевич Миримский Народився 2 квітня 1960(1960-04-02)Сімферополь, Кримська область, Українська РСР, СРСРПомер 27 квітня 2017(2017-04-27) (57 років)Київ, Україна·інсультПоховання Байкове кладовищеГромадянство  УкраїнаНаціональність єврейДіяльність Нар

Italian footballer and manager Cesare Maldini Maldini in 1969Personal informationFull name Cesare MaldiniDate of birth (1932-02-05)5 February 1932Place of birth Trieste, ItalyDate of death 3 April 2016(2016-04-03) (aged 84)Place of death Milan, ItalyHeight 1.83 m (6 ft 0 in)Position(s) DefenderYouth career1950–1952 TriestinaSenior career*Years Team Apps (Gls)1952–1954 Triestina 32 (0)1954–1966 AC Milan 347 (3)1966–1967 Torino 33 (0)Total 412 (3)International career...

 

Triathlon Charakterystyka Rodzaj sportu wielobój Popularność Dyscyplina olimpijska od 2000 Multimedia w Wikimedia Commons Start do etapu pływackiego Na trasie etapu pływackiego Zakończenie etapu pływackiego Początek i koniec etapu kolarskiego Triathlon (ang. triathlon), triatlon (gr. trójbój) – wszechstronna dyscyplina sportowa będąca kombinacją pływania, kolarstwa i biegania. Zawodnik kolejno płynie, jedzie na rowerze i biegnie, a czas końcowy obejmuje również zmian...

 

American singer-songwriter and actor (born 1967) This article needs to be updated. Please help update this article to reflect recent events or newly available information. (September 2023) Harry Connick Jr.Connick in April 2014BornJoseph Harry Fowler Connick Jr. (1967-09-11) September 11, 1967 (age 56)New Orleans, Louisiana, U.S.Occupations Singer composer actor television host Years active1977–presentSpouse Jill Goodacre ​(m. 1994)​Children3ParentHarr...

هذه المقالة يتيمة إذ تصل إليها مقالات أخرى قليلة جدًا. فضلًا، ساعد بإضافة وصلة إليها في مقالات متعلقة بها. (يوليو 2019) أنطوان ويليام ديلماس (بالفرنسية: Antoine Guillaume Delmas)‏    معلومات شخصية الميلاد 21 يونيو 1768  الوفاة 30 أكتوبر 1813 (45 سنة)   لايبزيغ  مواطنة فرنسا  الحياة ...

 

American astronaut Kjell LindgrenOfficial portrait, 2014Born (1973-01-23) January 23, 1973 (age 50)Taipei, TaiwanStatusActiveAlma materUnited States Air Force Academy (BS)Colorado State University (MS)University of Colorado, Aurora (MD)University of Minnesota (MS)University of Texas, Galveston (MPH)Space careerNASA AstronautTime in space312 days, 5 hours, 11 minutesSelection2009 NASA GroupTotal EVAs2Total EVA time15 hours and 04 minutesMissionsSoyuz TMA-17M (Expedition 44/45), Space...

 

Fictional character from Emmerdale Soap opera character Annie SugdenEmmerdale characterPortrayed bySheila MercierDuration1972–1996, 2009First appearanceEpisode 1 16 October 1972Last appearanceEpisode 5218/5219 10 February 2009ClassificationFormer; regularCreated byKevin LaffanIntroduced byDavid Goddard (1972)Mervyn Watson (1995, 1996)Anita Turner (2009)In-universe informationOther namesAnnie PearsonAnnie KempinskiAnnie BrearlyOccupationFarmerFatherSam PearsonMotherG...

Public historically black university in Frankfort, Kentucky, U.S. Kentucky State redirects here. For the U.S. state, see Kentucky. Kentucky State UniversityLatin: Statum Universitas KentuckiensisFormer nameState Normal School for Colored Persons (1886–1902)Kentucky Normal and Industrial Institute for Colored Persons (1902–1926)Kentucky State Industrial College for Colored Persons (1926–1938)Kentucky State College for Negroes (1938–1952)Kentucky State College (1952–1972)MottoOnward, ...

 

Species of fish Procottus major Conservation status Least Concern (IUCN 3.1)[1] Scientific classification Domain: Eukaryota Kingdom: Animalia Phylum: Chordata Class: Actinopterygii Order: Scorpaeniformes Family: Cottidae Genus: Procottus Species: P. major Binomial name Procottus majorTaliev, 1949 Synonyms[2] Procottus jeittelesi major Taliev, 1949 Procottus major is a species of ray-finned fish belonging to the family Cottidae, the typical sculpins. This species is e...

 

Inaugural season of the FIA Formula 3 Championship F3 2019 redirects here. For the car introduced to the championship in 2019, see Dallara F3 2019. 2019 FIA Formula 3 Championship Drivers' Champion: Robert Shwartzman Teams' Champion: Prema Racing Previous 2018 (F3 Europe)2018 (GP3) Next 2020 Parent series:Formula One World ChampionshipFIA Formula 2 Championship Robert Shwartzman became the first FIA Formula 3 Champion, while his team Prema Racing won the Teams' Championship. Prema R...

American football player (born 1989) American football player Lane TaylorTaylor with the Green Bay Packers in 2016Personal informationBorn: (1989-11-22) November 22, 1989 (age 34)Arlington, Texas, U.S.Height:6 ft 3 in (1.91 m)Weight:324 lb (147 kg)Career informationHigh school:Martin (Arlington, Texas)College:Oklahoma StatePosition:GuardUndrafted:2013Career history Green Bay Packers (2013–2020) Houston Texans (2021) Roster status:ActiveCareer highlights and awa...

 

Drakas! AuthorS. M. StirlingCover artistStephen HickmanCountryUnited StatesLanguageEnglishSeriesThe DominationGenreDystopian alternate historyPublisherBaen BooksPublication dateOctober 31, 2000Pages384ISBN0-671-31946-9Followed byDrakon  Drakas! is a science fiction anthology, containing stories set in S. M. Stirling's alternate history series The Domination.[1][2] The anthology was released in the United States on October 31, 2000. Contents Custer Under the Baob...

 

South African firearms manufacturer Truvelo Armoury is a South African firearms manufacturer. It is a division of Truvelo Specialised Manufacturing (Pty) Ltd. Based in Midrand (Johannesburg) the company produces a range of rifles and other small arms for military, law enforcement and civilian users.[1][2] Products Anti Material Rifles Sniper Rifles[3] Assault Rifles[4] Rifle Accessories Hunting Rifles Rifle Actions and Barrels Submachine guns Truvelo 12.7×99mm...

Ukrainian singer and songwriter (born 1982) In this name that follows Eastern Slavic naming conventions, the patronymic is Oleksandrivna and the family name is Meikher. Nadia MeiherНадія Олександрівна УржумцеваBackground informationBirth nameНадія Олександрівна МейхерBorn (1982-04-10) 10 April 1982 (age 41)Zbruchivka, Volochysk Raion, Ukrainian SSR, Soviet UnionOriginUkraineGenrespopOccupation(s)singeractressYears active2000–presen...

 

This article does not cite any sources. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: The Savage Five – news · newspapers · books · scholar · JSTOR (May 2014) (Learn how and when to remove this template message) 1974 Hong Kong filmThe Savage FiveFilm posterTraditional Chinese五虎將Simplified Chinese五虎将Hanyu PinyinWǔ Hǔ JiàngJyutpingNg2 Fu2 Zeong3...

 

Artikel ini membutuhkan rujukan tambahan agar kualitasnya dapat dipastikan. Mohon bantu kami mengembangkan artikel ini dengan cara menambahkan rujukan ke sumber tepercaya. Pernyataan tak bersumber bisa saja dipertentangkan dan dihapus.Cari sumber: Pertanda – berita · surat kabar · buku · cendekiawan · JSTOR (Juli 2021) Contoh pertanda dari Nuremberg Chronicle (1493): fenomena alami dan kelahiran tak wajar. Manuskrip dari pertengahan abad ke-19, yang ke...

Intipan huruf Kisah Para Rasul 28Kisah Para Rasul 28:30-31 pada Uncial 0166 (abad ke-5).KitabKisah Para RasulKategoriSejarah gerejaBagian Alkitab KristenPerjanjian BaruUrutan dalamKitab Kristen5← pasal 27 Roma 1 → Kisah Para Rasul 28 (disingkat Kis 28) adalah pasal terakhir Kitab Kisah Para Rasul dalam Perjanjian Baru di Alkitab Kristen. Ditulis oleh Lukas, seorang Kristen yang merupakan teman seperjalanan Rasul Paulus.[1] Berisi riwayat perjalanan Rasul Paulus ke Roma set...

 

Indian politician Arvind Kumar SharmaMember of Parliament, Lok SabhaIncumbentAssumed office 23 May 2019Preceded byDeepender Singh HoodaConstituencyRohtakIn office2004–2014Preceded byIshwar Dayal SwamiSucceeded byAshwini Kumar ChopraConstituencyKarnal Personal detailsBorn (1962-11-25) 25 November 1962 (age 61)M.P. Majra, Punjab, India(now in Haryana, India)Political partyBharatiya Janata Party (2014–present)Other politicalaffiliationsIndian National Congress (till 2014)Spouse Rita...

 

Strategi Solo vs Squad di Free Fire: Cara Menang Mudah!