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.
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?
- -E uses POSIX extended regular expressions, which are portable and cover word boundaries, groups and alternation. -P uses PCRE for lookaround and lazy quantifiers, but it is a GNU feature and not available on every system.
- How do I pass several extensions?
- Type one include pattern at a time, or a shell expansion such as a brace list you write yourself. The builder writes one --include for whatever you enter.