

Unfortunately, even a relatively simple pattern like a phone number can result in a "scary" looking regex string. This tool can be intimidating to newbies and experienced Linux users alike. This means it's important to know the rules for your particular regex processor.Ī practical example of grep: Matching phone numbers There are similar capabilities across the range of tools, but meta characters and syntax can vary. It should be noted that grep is just one tool that uses regex. These special characters that make this search tool much more powerful. Patterns can be found easier by using meta-characters. It can be used to find any kind of pattern imaginable. Regex is capable of much more than keyword searches, though. Regular expressions are used to identify, match, or otherwise manage text. 🤓 What is a Regular Expression, again?Ī regular expression (or regex) can be thought of as kind of like a search query. Feel free to share this fun fact with your friends at your Hamilton watch party. If you think about it, that means Alexander Hamilton technically helped create grep. So, Thompson transformed the search feature into a standalone utility, independent of the ed editor. The original Unix text editor, ed, (also created by Thompson) wasn't capable of searching such a large body of text given the hardware limitations of the time. But since these articles were anonymous, the scientist was trying to identify the authors based on linguistic pattern. This extensive body of work was a collection of 85 anonymous articles and essays drafted in defense of the United States Constitution. This scientist's goal was to examine linguistic patterns to identify the authors (including Alexander Hamilton) of the Federalist Papers. Thompson built grep to assist one of his colleagues at Bell Labs.

He helped create Unix, popularized its modular approach, and wrote many of its programs including grep. Ken Thompson has made some incredible contributions to computer science. The interesting story behind creation of grep This is the official narrative, but you may also see it described as Global Regular Expression ( Processor | Parser | Printer). It is much faster at searching large files. It performs a global research for a regular expression and prints it. The grep command does what the g/re/p commands did in the editor. In which, the input g/re/p performed a global (g) search for a regular expression (re), and subsequently printed (p) any matching lines. This is at least partially true, but it depends on who you ask.Īccording to reputable sources, the name is actually derived from a command in a UNIX text editor called ed. With its unusual name, you may have guessed that grep is an acronym.

It is used for finding a search patterns in the content of a given file. Grep is a command line utility in Unix and Linux systems. In this explainer article, I'll tell you what is grep command and how does it work. If you use Linux for regular work or developing and deploying software, you must have come across the grep command.
