

They are the same as grep -E, grep -F and grep -R respectively, but are deprecated as standalone tools and only provided because some software still relies on them.

What's worth noting is that nowadays, grep is a family of tools, which includes egrep, fgrep and rgrep. It should be considered rather experimental when used with certain options and is recommended only for advanced users. This variant still has some unimplemented features and might produce warnings.

-P or -perl-regexp - Interprets the pattern as Perl-Compatible Regular Expressions (PCREs).-F or -fixed-strings - Interprets the pattern as fixed strings, not regular expressions.-E or -extended-regexp - Interprets the pattern as an Extended Regular Expression (ERE).This variant is used by default (if no other options are specified). -G or -basic-regexp - When used, it interprets the pattern as a Basic Regular Expression (BRE).Depending on which suits our needs best, we pick the one we'll use by specifying the OPTION argument: ), if the recursion option is given otherwise grep searches the standard input pipe. If there is no FILE argument specified, grep searches through the working directory (. We can specify zero or more OPTION arguments, one or more PATTERNS and zero or more FILE arguments. The general form of the grep command is: $ grep In this article, we will learn the basics of grep and its usage by running through its options and some examples. When he presented the tool the next day, it really did seem like it was written in no time. He responded that he'll think of something overnight - while he actually used that time to improve the code and fix some bugs. The interesting part of the story is that his manager approached him, asking for a tool that does exactly that. By default, it searches through an input and prints a single or multiple lines that contain text matched to a pattern specified in the command call.īefore grep became such a widespread tool for the GNU/Linux system, it used to be a private utility written by Ken Thompson for searching through files. Grep is a powerful, yet very simple tool.
