It’s like grep with a superpower - it searches through every subdirectory.Īnd then there’s egrep , which is the same as grep -E, though the grep man page warns that egrep “is deprecated,” but “is provided to allow historical applications that rely on them to run unmodified.” Searches with egrep match not only the usual metacharacters ( .* ^ $) but also the Posix-defined set of (E)xtended regular expressions. For example, there’s the recursive rgrep, which is the same as grep -r. History has it that Ken Thompson coded up the grep tool overnight to help a colleague search through the entire text of the Federalist Papers without having to load the whole thing into memory first.īut in the same way that the ed command g/ re/p became a stand-alone tool named “grep,” some of grep’s most useful flags eventually spun off into more tools. Yes, it was such a useful command that eventually became its own stand-alone tool. For example, ed is the forefather of the ex text editor, much of which ended up incorporated into vim.)Īnd if you wrote out the one-line ed command for finding a regular expression re - searching “globally” throughout the entire document, and then printing every match - you’d get… This explains why text editors like ed worked on one line at a time - a tradition which found its ways into many Unix tools which have since been handed down over the last 40 years. Back then Unix was running on a slow, low-memory PDP-11 - and “It’s possible that if you took the output of one program and had to store it, totally, before you put it into the next program, it might not fit.” To understand the evolution of grep, “You have to put yourself back in the early days of computing… the very, very early days of Unix,” Brian Kernighan recently remembered in some new interviews. And it turns out that some of that usefulness lies rooted in the work of the early Unix pioneers. Part of the Unix batch of utilities, grep(Global Regular Expression Print) is such a powerful search tool, that it makes sense to review all its flags and meta-characters to make sure you’re not overlooking something incredibly useful.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |