grep Pattern Builder
Build a grep command with the right regex style, recursion, includes and context lines, then copy it.
grep Pattern Builder
Command
The path is left unquoted so a glob like src/*.js still expands in your shell.
Learn
History for this tool
The most recent data you entered in this tool, stored only in this browser.
Save what you type here, in this browser? Your work would go into this browser's local storage, so a refresh or a trip to another tool does not wipe it. You also get a short list of previous entries under the form, each one restorable with a click. Nothing is ever uploaded, and there is no account.
Being straight about the trade-off: anything kept there can be read by anyone who can use this browser profile, and by any script that later runs on this site. A tool page can hold a private key, a password or a signed token. Saving is convenient; it is not private.
About this tool
Put together a grep command with the right regex flavour and the flags that keep the output readable. Pick extended, basic, fixed or Perl patterns, choose recursion, case, line numbers, context and file filters, and the page builds the command with the pattern safely quoted.Questions
- When should I use -F?
- When you are searching for literal text that contains regex characters, such as an IP address with dots or a string with brackets. -F treats the pattern as plain text, so nothing needs escaping.
- What is the difference between -E and -P?
-Euses extended regular expressions for groups and alternation.-Prequests Perl-compatible patterns such as lookarounds, but not every version of grep supports it. Test on the machine where you will run the command.- How do I pass several extensions?
- The builder writes one
--includefor the exact text in the field and shell-quotes it. To use several patterns, add separate--includeoptions to the copied command yourself; brace expansion inside the quoted field will not expand.