a more powerful, ultra fast, user-friendly, compatible grep (that is also completely free!)
ugrep installs on
brew install ugrep
port install ugrep
winget install Genivia.ugrep
choco install ugrep
scoop install ugrep
apk add ugrep ugrep-doc
pkg install ugrep
pacman -S ugrep
dnf install ugrep
apt-get install ugrep
dnf install ugrep
pkg install ugrep
pkg_add ugrep
zypper install ugrep
dnf install ugrep
git clone https://github.com/Genivia/ugrep cd ugrep ./build.sh # build ug and ugrep in ugrep/bin sudo make install # install as desired
how fast is ugrep?
Search with a TUI (shown) or from the command line with grep-compatible options. You can also Google search (shown) and fuzzy search your files. Search (nested) zip/7z/tar/pax/cpio archives, tarballs and compressed files, search and hexdump binary, search PDF, doc, docx, and much more. Supports Unicode extended regex pattern syntax and multi-line pattern matching by default and does not require specialized command-line options.
Search for patterns in files with the ug
and ugrep
commands, where
ug+
command also searches pdfs, documents, e-books, image metadataugrep
works best in shell scripts;ugrep+
command also searches pdfs, documents, e-books, image metadataExamples:
ls DIR
takes a DIR to list)Usage tips:
egrep
, but supporting Unicode by default
ugrep
to grep
, egrep
and fgrep
; it emulates according to these names
Ugrep is compatible with GNU grep and supports GNU grep command-line options. But ugrep also offers new options and features. In general, command-line options can be mixed and specified in any order. Long options --OPTION may start with --no-OPTION to disable them. All short options have long alternatives. This page shows short options for the most part. Specify --stats to output a final summary search report of options, patterns, and search statistics.
Usage tips:
fgrep
or grep -F
grep
or grep -G
Usage tips:
Usage tips:
Usage tips:
Usage tips:
Usage tips:
Usage tips:
Usage tips:
ug
enables --pretty and --sort by default
ugrep
only enables --color by default
. | any character except \n |
a | the character a |
ab | the string ab |
a|b | a or b |
a* | zero or more a's |
a+ | one or more a's |
a? | zero or one a |
a{3} | 3 a's |
a{3,} | 3 or more a's |
a{3,7} | 3 to 7 a's |
a*? | zero or more a's lazily |
a+? | one or more a's lazily |
a?? | zero or one a lazily |
a{3}? | 3 a's lazily |
a{3,}? | 3 or more a's lazily |
a{3,7}? | 3 to 7 a's lazily |
\. | escapes . to match . |
\Q...\E | the literal string ... |
\f | form feed |
\n | newline |
\r | carriage return |
\R | any Unicode line break |
\t | tab |
\v | vertical tab |
\X | any character and \n |
\cZ | control character ^Z |
\0 | NUL |
\0ddd | octal character code ddd |
\xhh | hex character code hh |
\x{hhhh} | Unicode code point U+hhhh |
\u{hhhh} | Unicode code point U+hhhh |
[abc-e] | one character a,b,c,d,e |
[^abc-e] | one char not a,b,c,d,e,\n |
[[:alnum:]] | a letter or decimal digit |
[[:alpha:]] | a lower or uppercase letter |
[[:ascii:]] | ASCII char \x00-\x7f |
[[:blank:]] | a space or a tab |
[[:cntrl:]] | a control character |
[[:digit:]] | a decimal digit |
[[:graph:]] | a visible character |
[[:lower:]] | a lowercase letter |
[[:print:]] | a visible char or space |
[[:punct:]] | a punctuation character |
[[:space:]] | a space,\t,\v,\f,\r |
[[:upper:]] | an uppercase letter |
[[:word:]] | a word-like character |
[[:xdigit:]] | a hexadecimal digit |
\p{Class} | one character in Class |
\P{Class} | one char not in Class |
\d | a decimal digit |
\D | a non-digit character |
\h | a space or a tab |
\H | not a space or a tab |
\l | a lowercase letter |
\L | a non-lowercase character |
\s | a whitespace except \n |
\S | a non-whitespace |
\u | an uppercase letter |
\U | a non-uppercase character |
\w | a word-like character |
\W | a non-word character |
^ | begin of line anchor |
$ | end of line anchor |
\A | begin of file anchor |
\Z | end of file anchor |
\b | word boundary |
\B | non-word boundary |
\< | start of word boundary |
\> | end of word boundary |
(?=...) | lookahead (-P) |
(?!...) | negative lookahead (-P) |
(?<=...) | lookbehind (-P) |
(?<!...) | negative lookbehind (-P) |
(...) | capturing group (-P) |
(...) | non-capturing group |
(?:...) | non-capturing group |
(?<X>...) | capturing, named X (-P) |
\1 | matches group 1 (-P) |
\g{10} | matches group 10 (-P) |
\g{X} | matches group name X (-P) |
(?#...) | comments ... are ignored |
ASCII | any ASCII character |
Unicode | any Unicode character except \n |
Non_ASCII_Unicode | any non-ASCII Unicode character |
Alpha | Ll or Lu, same as [[:alpha:]] |
Alnum | Ll or Lu or Nd, same as [[:alnum:]] |
Space | Zs or \t,\v,\f,\r whitespace, same as \s or [[:space:]] |
Word | L or Nd or Pc, same as \w or [[:word:]] |
L& | Ll or Lu or Lt |
L or Letter | Ll or Lu or Lt or Lm or Lo |
M or Mark | Mn or Mc or Me |
Z or Separator | Zs or Zl or Zp |
S or Symbol | Sm or Sc or Sk or So |
N or Number | Nd or Nl or No |
P or Punctuation | Pd or Ps or Pe or Pi or Pf or Pc or Po, same as [[:punct:]] |
C or Other | Cc or Cf, same as [[:cntrl:]] |
Ll or Lower or Lowercase_Letter | a lower case letter, same as \l or [[:lower:]] |
Lu or Upper or Uppercase_Letter | an upper case letter, same as \u or [[:upper:]] |
Lt or Titlecase_Letter | a title case letter |
Lm or Modifier_Letter | a modifier letter |
Lo or Other_Letter | any other letter |
Mn or Non_Spacing_Mark | a nonspacing mark |
Mc or Spacing_Combining_Mark | a spacing mark |
Me or Enclosing_Mark | an enclosing mark |
Zs or Space_Separator | a space separator |
Zl or Line_Separator | a line separator |
Zp or Paragraph_Separator | a paragraph separator |
Sm or Math_Symbol | a math symbol |
Sc or Currency_Symbol | a currency symbol |
Sk or Modifier_Symbol | a modifier symbol |
So or Other_Symbol | any other symbol |
Nd or Decimal_Digit_Number | a decimal number, same as \d or [[:digit:]] |
Nl or Letter_Number | a letter number |
No or Other_Number | any other number |
Pd or Dash_Punctuation | a dash punctuation |
Ps or Open_Punctuation | an open punctuation |
Pe or Close_Punctuation | a close punctuation |
Pi or Initial_Punctuation | an initial punctuation |
Pf or Final_Punctuation | a final punctuation |
Pc or Connector_Punctuation | a connector punctuation |
Po or Other_Punctuation | any other punctuation |
Cc or Control | a control character |
Cf or Format | a format character |
UnicodeIdentifierStart | L or Nl |
UnicodeIdentifierPart | L or Nl or Mn or Mc or Nd or Cf or IdentifierIgnorable |
IdentifierIgnorable | U+0000~0008,000E~001B,007F,0080~009F |
JavaIdentifierStart | L or Nl or Sc or Pc |
JavaIdentifierPart | L or Nl or Sc or Pc or Mn or Mc or Nd or Cf |
CsIdentifierStart | L or Nl or Pc or '@' |
CsIdentifierPart | L or Nl or Pc or Mn or Mc or Nd or Cf |
PythonIdentifierStart | a start of Python identifier character |
PythonIdentifierPart | a Python identifier character |
IsBlock | a character in the specified Unicode Block |
Language | a character in the specified Language |
Ugrep supports gitignore-style globbing for all glob-related options -g, --iglob=, --exclude=, --include=, -include-dir=, --exclude-dir=, --include-from=, --exclude-from=, and --ignore-files, where
* | matches anything except / |
? | matches any one character except / |
[abc-e] | matches one character a,b,c,d,e |
[^abc-e] | matches one character not a,b,c,d,e,/ |
[!abc-e] | matches one character not a,b,c,d,e,/ |
/ | when used at the start of a glob, matches the working directory |
**/ | matches zero or more directories on a path |
/** | when at the end of a glob, matches all paths after the / |
\? | matches a ? or any other character specified after the backslash |
The -t or --file-type= argument is a comma-separated list of file types. A file type is associated with one or more filename extensions, internally using option -O to match filename extensions. For capitalized file types, the search is expanded to include files with matching file signature magic bytes, internally using option -M. When a type is preceded by a ! or a ^, excludes files of the specified type.
actionscript | = | -O as,mxml | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ada | = | -O ada,adb,ads | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
asm | = | -O asm,s,S | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
asp | = | -O asp | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
aspx | = | -O master,ascx,asmx,aspx,svc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
autoconf | = | -O ac,in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
automake | = | -O am,in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
awk | = | -O awk | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Awk | = | -O awk | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-M '#!\h*/.*\Wg?awk(\W.*)?\n' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
basic | = | -O bas,BAS,cls,frm,ctl,vb,resx | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
batch | = | -O bat,BAT,cmd,CMD | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
bison | = | -O y,yy,ymm,ypp,yxx | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
c | = | -O c,h,H,hdl,xs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
c++ | = | -O cpp,CPP,cc,cxx,CXX,h,hh,H,hpp,hxx,Hxx,HXX | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
clojure | = | -O clj | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cpp | = | -O cpp,CPP,cc,cxx,CXX,h,hh,H,hpp,hxx,Hxx,HXX | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
csharp | = | -O cs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
css | = | -O css | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
csv | = | -O csv | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
dart | = | -O dart | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Dart | = | -O dart | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-M '#!\h*/.*\Wdart(\W.*)?\n' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
delphi | = | -O pas,int,dfm,nfm,dof,dpk,dproj,groupproj,bdsgroup,bdsproj | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
elisp | = | -O el | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
elixir | = | -O ex,exs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
erlang | = | -O erl,hrl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fortran | = | -O for,ftn,fpp,f,F,f77,F77,f90,F90,f95,F95,f03,F03 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
gif | = | -O gif | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Gif | = | -O gif | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-M 'GIF87a|GIF89a' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
go | = | -O go | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
groovy | = | -O groovy,gtmpl,gpp,grunit,gradle | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
gsp | = | -O gsp | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
haskell | = | -O hs,lhs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
html | = | -O htm,html,xhtml | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
jade | = | -O jade | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
java | = | -O java,properties | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
jpeg | = | -O jpg,jpeg | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Jpeg | = | -O jpg,jpeg | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-M '\xff\xd8\xff[\xdb\xe0\xe1\xee]' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
js | = | -O js | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
json | = | -O json | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
jsp | = | -O jsp,jspx,jthm,jhtml | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
julia | = | -O jl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
kotlin | = | -O kt,kts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
less | = | -O less | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
lex | = | -O l,ll,lmm,lpp,lxx | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
lisp | = | -O lisp,lsp | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
lua | = | -O lua | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
m4 | = | -O m4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
make | = | -O mk,mak | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-g makefile,Makefile,Makefile.Debug,Makefile.Release | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
markdown | = | -O md | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
matlab | = | -O m | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
node | = | -O js | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Node | = | -O js | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-M '#!\h*/.*\Wnode(\W.*)?\n' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
objc | = | -O m,h | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
objc++ | = | -O mm,h | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ocaml | = | -O ml,mli,mll,mly | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
parrot | = | -O pir,pasm,pmc,ops,pod,pg,tg | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
pascal | = | -O pas,pp | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
= | -O pdf | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
= | -O pdf | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-M '\x25\x50\x44\x46\x2d' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
perl | = | -O pl,PL,pm,pod,t,psgi
Perl | = | -O pl,PL,pm,pod,t,psgi | | | -M '#!\h*/.*\Wperl(\W.*)?\n' | php | = | -O php,php3,php4,phtml | Php | = | -O php,php3,php4,phtml | | | -M '#!\h*/.*\Wphp(\W.*)?\n' | png | = | -O png | Png | = | -O png | | | -M '\x89PNG\x0d\x0a\x1a\x0a' | prolog | = | -O pl,pro | python | = | -O py | Python | = | -O py | | | -M '#!\h*/.*\Wpython[23]?(\W.*)?\n' | r | = | -O R | rpm | = | -O rpm | Rpm | = | -O rpm | | | -M '\xed\xab\xee\xdb' | rst | = | -O rst | rtf | = | -O rtf | Rtf | = | -O rtf | | | -M '\{\rtf1' | ruby | = | -O rb,rhtml,rjs,rxml,erb,rake,spec | | | -g Rakefile | Ruby | = | -O rb,rhtml,rjs,rxml,erb,rake,spec | | | -g Rakefile | | | -M '#!\h*/.*\Wruby(\W.*)?\n' | rust | = | -O rs | scala | = | -O scala | scheme | = | -O scm,ss | shell | = | -O sh,bash,dash,csh,tcsh,ksh,zsh,fish | Shell | = | -O sh,bash,dash,csh,tcsh,ksh,zsh,fish | | | -M '#!\h*/.*\W(ba|da|t?c|k|z|fi)?sh(\W.*)?\n' | smalltalk | = | -O st | sql | = | -O sql,ctl | svg | = | -O svg | swift | = | -O swift | tcl | = | -O tcl,itcl,itk | tex | = | -O tex,cls,sty,bib | text | = | -O text,txt,TXT,md,rst | tiff | = | -O tif,tiff | Tiff | = | -O tif,tiff | | | -M '\x49\x49\x2a\x00|\x4d\x4d\x00\x2a' | tt | = | -O tt,tt2,ttml | typescript | = | -O ts,tsx | verilog | = | -O v,vh,sv | vhdl | = | -O vhd,vhdl | vim | = | -O vim | xml | = | -O xml,xsd,xsl,xslt,wsdl,rss,svg,ent,plist | Xml | = | -O xml,xsd,xsl,xslt,wsdl,rss,svg,ent,plist | | | -M '<\?xml ' | yacc | = | -O y | yaml | = | -O yaml,yml | zig | = | -O zig,zon | |
A filter utility is associated with one or more filename extensions using the syntax --filter="ext1,ext2,ext3:command". Options to the specified command may be included. The special option % is expanded into the pathname of the file to search. Filters are applied first when the filename extension matches one of the specified filters, then the output of the filter is searched. Some examples:
ug+
ug+
ug+
ug+
The --colors= argument is a colon-separated list of parameters, such as --colors=sl=hy:mt=hyB, where
sl= | selected lines |
cx= | context lines |
rv | swaps the sl= and cx= capabilities when -v is specified |
mt= | matching text in any matching line |
ms= | matching text in a selected line, the substring mt= by default |
mc= | matching text in a context line, the substring mt= by default |
fn= | file names |
ln= | line numbers |
cn= | column numbers |
bn= | byte offsets |
se= | separators |
hl | hyperlink file names, same as --hyperlink |
qp= | TUI prompt |
qe= | TUI errors |
qr= | TUI regex |
qm= | TUI regex meta characters |
ql= | TUI regex lists and literals |
qb= | TUI regex braces |
Multiple SGR codes may be specified for a single parameter when separated by a semicolon, for example --colors="mt=1;31" specifies bright red. For quick and easy color specification, the corresponding single-letter color names may be used in place of numeric SGR codes and semicolons are not required to separate color names, for example --colors=mt=hr specifies bright red. Color letters and numeric codes may be mixed. The following SGR codes have corresponding letter designations:
0 | n | normal font and color | 2 | f | faint (not widely supported) |
1 | h | highlighted bold font | 21 | H | highlighted bold off |
4 | u | underline | 24 | U | underline off |
7 | i | invert video | 27 | I | invert off |
30 | k | black text | 90 | +k | bright gray text |
31 | r | red text | 91 | +r | bright red text |
32 | g | green text | 92 | +g | bright green text |
33 | y | yellow text | 93 | +y | bright yellow text |
34 | b | blue text | 94 | +b | bright blue text |
35 | m | magenta text | 95 | +m | bright magenta text |
36 | c | cyan text | 96 | +c | bright cyan text |
37 | w | white text | 97 | +w | bright white text |
40 | K | black background | 100 | +K | bright gray background |
41 | R | dark red background | 101 | +R | bright red background |
42 | G | dark green background | 102 | +G | bright green background |
43 | Y | dark yellow backgrounda | 103 | +Y | bright yellow background |
44 | B | dark blue background | 104 | +B | bright blue background |
45 | M | dark magenta background | 105 | +M | bright magenta background |
46 | C | dark cyan background | 106 | +C | bright cyan background |
47 | W | dark white background | 107 | +W | bright white background |
The default color scheme is cx=33: mt=1;31: fn=1;35: ln=1;32: cn=1;32: bn=1;32: se=36: qp=1;32: qe=1;37;41: qm=1;32: ql=36: qb=1;35
Formatted output and match replacement puts you in full control of the output. In fact, CSV (--csv), JSON (--json) and XML (--xml) are all produced this way.
--format-begin="FORMAT" | format string for beginning the search |
--format-open="FORMAT" | format string for opening a file when a match was found |
--format="FORMAT" | format string for each match in a file |
--format-close="FORMAT" | format string for closing a file when a match was found |
--format-end="FORMAT" | format string for ending the search |
--replace="FORMAT" | replace matches in the output with the specified formatted string |
where FORMAT may contain any text and the following format fields:
%F | if option -H is used: the file pathname and separator |
%[TEXT]F | if option -H is used: TEXT, the file pathname and separator |
%f | the file pathname |
%a | the file basename without directory path |
%p | the directory path to the file |
%z | the pathname in a (compressed) archive, without { and } |
%H | if option -H is used: the quoted pathname and separator, \" and \\ replace " and \ |
%[TEXT]H | if option -H is used: TEXT, the quoted pathname and separator, \" and \\ replace " and \ |
%h | the quoted file pathname, \" and \\ replace " and \ |
%N | if option -n is used: the line number and separator |
%[TEXT]N | if option -n is used: TEXT, the line number and separator |
%n | the line number of the match |
%K | if option -k is used: the column number and separator |
%[TEXT]K | if option -k is used: TEXT, the column number and separator |
%k | the column number of the match |
%B | if option -b is used: the byte offset and separator |
%[TEXT]B | if option -b is used: TEXT, the byte offset and separator |
%b | the byte offset of the match |
%T | if option -T is used: TEXT and a tab character |
%[TEXT]T | if option -T is used: TEXT and a tab character |
%t | a tab character |
%[SEP]$ | set field separator to SEP for the rest of the format fields |
%[TEXT]< | if the first match: TEXT |
%[TEXT]> | if not the first match: TEXT |
%, | if not the first match: a comma, same as %[,]< |
%: | if not the first match: a colon, same as %[:]> |
%; | if not the first match: a semicolon, same as %[;]> |
%| | if not the first match: a vertical bar, same as %[|]> |
%S | if not the first match: separator, see also %[SEP]$ |
%[TEXT]S | if not the first match: TEXT and separator, see also %[SEP]$ |
%s | the separator, see also %[TEXT]S and %[SEP]$ |
%~ | a newline character |
%+ | if option --heading is used: %F and a newline character, suppress all %F and %H afterward |
%m | the number of matches, sequential (or number of matching files with --format-end) |
%M | the number of matching lines (or number of matching files with --format-end) |
%O | the matching line is output as is (a raw string of bytes) |
%o | the match is output as is (a raw string of bytes) |
%Q | the matching line as a quoted string, \" and \\ replace " and \ |
%q | the match as a quoted string, \" and \\ replace " and \ |
%C | the matching line formatted as a quoted C/C++ string |
%c | the match formatted as a quoted C/C++ string |
%J | the matching line formatted as a quoted JSON string |
%j | the match formatted as a quoted JSON string |
%V | the matching line formatted as a quoted CSV string |
%v | the match formatted as a quoted CSV string |
%X | the matching line formatted as XML character data |
%x | the match formatted as XML character data |
%w | the width of the match, counting (wide) characters |
%d | the size of the match, counting bytes |
%e | the ending byte offset of the match |
%Z | the edit distance cost of an approximate match with option -Z |
%u | select unique lines only unless option -u is used |
%1 %2 ... %9 | the first regex group capture of the match, and so on up to group %9, requires option -P |
%[NUM]# | the regex group capture NUM; requires option -P |
%[NUM]b | the byte offset of the group capture NUM; requires option -P |
%[NUM]e | the ending byte offset of the group capture NUM; requires option -P |
%[NUM]d | the byte length of the group capture NUM; requires option -P |
%[NUM1|NUM2|...]# | the first group capture NUM in the list that matched; requires option -P |
%[NUM1|NUM2|...]b | the byte offset of the first group capture NUM in the list that matched; requires option -P |
%[NUM1|NUM2|...]e | the ending byte offset of the first group capture NUM in the list that matched; requires option -P |
%[NUM1|NUM2|...]d | the byte length of the first group capture NUM in the list that matched; requires option -P |
%[NAME]# | the NAMEd group capture; requires option -P and capturing pattern (?<NAME>PATTERN) |
%[NAME]b | the byte offset of the NAMEd group capture; requires option -P and capturing pattern (?<NAME>PATTERN) |
%[NAME]e | the ending byte offset of the NAMEd group capture; requires option -P and capturing pattern (?<NAME>PATTERN) |
%[NAME]d | the byte length of the NAMEd group capture; requires option -P and capturing pattern (?<NAME>PATTERN) |
%[NAME1|NAME2|...]# | the first NAMEd group capture in the list that matched; requires option -P and capturing pattern (?<NAME>PATTERN) |
%[NAME1|NAME2|...]b | the byte offset of the first NAMEd group capture in the list that matched; requires option -P and capturing pattern (?<NAME>PATTERN) |
%[NAME1|NAME2|...]e | the ending byte offset of the first NAMEd group capture in the list that matched; requires option -P and capturing pattern (?<NAME>PATTERN) |
%[NAME1|NAME2|...]d | the byte length of the first NAMEd group capture in the list that matched; requires option -P and capturing pattern (?<NAME>PATTERN) |
%G | all group capture indices/names of the match |
%[TEXT1|TEXT2|...]G | all TEXT indexed by group capture indices that matched; requires option -P |
%g | the group capture index of the match or 1 |
%[TEXT1|TEXT2|...]g | the TEXT indexed by the first group capture index that matched; requires option -P |
%% | the percentage sign |
--format-open='%+' --format='%[,]$%H%N%K%B%V%~%u'
--format-begin='[' --format-open='%,%~ {%~ %[,%~ ]$%["file": ]H"matches": [' --format='%,%~ { %[, ]$%["line": ]N%["column": ]K%["offset": ]B"match": %J }%u' --format-close='%~ ]%~ }' --format-end='%~]%~'
--format-begin='<grep>%~' --format-open=' <file%[]$%[ name=]H>%~' --format=' <match%[\"]$%[ line=\"]N%[ column=\"]K%[ offset=\"]B>%X</match>%~%u' --format-close=' </file>%~' --format-end='</grep>%~'
The ugrep-indexer command indexes a directory tree to accelerate searching slow file systems and file systems that are "cold" i.e. not recently cached in memory. Indexing accelerates recursive searching by performing a quick check on precomputed indexes to only search those files that may match.
Indexed-based search with ugrep is safe and never skips new or updated files that may now match. If any files and directories are added or changed after indexing, then ugrep will search these additions and changes made to the file system by comparing file and directory time stamps to the indexing time stamp. When many files were added or changed, then you may want to re-index to bring the indexes up to date. Re-indexing is incremental, it will not take as much time as the initial indexing process.
Please note that indexing is effective for large file systems on slower storage media or when searching many zip and tarball archives. Indexing won't speed up regular file searching on fast nVME SSDs, for example.
Usage tips:
If you found a bug or an issue, then please report it at https://github.com/Genivia/ugrep/issues
Ugrep is open source BSD-3 licensed:
Permissions |
---|
✔️ commercial use |
✔️ modification |
✔️ distribution |
✔️ private use |
Limitations |
---|
❌ liability |
❌ warranty |
Conditions |
---|
ⓘ include license |
ⓘ copyright notice |
Ugrep is written by Robert A. van Engelen, Copyright (c) 2024 Robert A. van Engelen, Genivia Inc.
The ugrep author received the 🏆 Google Peer Bonus Award 2022 for developing ugrep
Ugrep project repo: https://github.com/Genivia/ugrep ⭐️ thank you for starring the project!
Ugrep uses the RE/flex regex library: https://github.com/Genivia/RE-flex
Ugrep option -P uses the PCRE2 library: https://www.pcre.org
See also: gnu grep, bsd grep, git grep, pcre grep, agrep, ack, ag, rg, sift
Last updated: Sat July 20, 2024