a more powerful, ultra fast, user-friendly, compatible grep
ugrep installs on
brew 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
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/tar/pax/cpio archives, tarballs and compressed files, search and hexdump binary, search PDF, doc, docx, and much more.
Search for patterns in files with the ug
and ugrep
commands, where
ug+
command also searches pdfs, documents, e-books, image metadataug
, but does not use a .ugrep configuration file: ugrep
works best in shell scripts;ugrep+
command also searches pdfs, documents, e-books, image metadataExamples:
ls DIR
takes a DIR to list)egrep
, but also adds syntax to support Unicode by default
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.
fgrep
grep
or grep -G
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-z,A-Z,0-9 |
[[:alpha:]] | a-z,A-Z |
[[:ascii:]] | ASCII char \x00-\x7f |
[[:blank:]] | space or tab |
[[:cntrl:]] | control characters |
[[:digit:]] | 0-9 |
[[:graph:]] | visible characters |
[[:lower:]] | a-z |
[[:print:]] | visible chars and space |
[[:punct:]] | punctuation characters |
[[:space:]] | space,\t,\v,\f,\r |
[[:upper:]] | A-Z |
[[:word:]] | a-z,A-Z,0-9,_ |
[[:xdigit:]] | 0-9,a-f,A-F |
\p{Class} | one character in Class |
\P{Class} | one char not in Class |
\d | a digit |
\D | a non-digit |
\h | a space or tab |
\H | not a space or tab |
\s | a whitespace except \n |
\S | a non-whitespace |
\w | a word character |
\W | a non-word character |
^ | begin of line anchor |
$ | end of line 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 |
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 |
/** | when at the end of a glob, matches everything after the / |
\? | matches a ? or any other character specified after the backslash |
The -t argument is a comma-separated list of file types. A file type matches one or more filename extensions, internally using option -O for filename extension matching. 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
--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 that matched; requires option -P |
%[NUM1|NUM2|...]b | the byte offset of the first group capture NUM that matched; requires option -P |
%[NUM1|NUM2|...]e | the ending byte offset of the first group capture NUM that matched; requires option -P |
%[NUM1|NUM2|...]d | the byte length of the first group capture NUM 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 that matched; requires option -P and capturing pattern (?<NAME>PATTERN) |
%[NAME1|NAME2|...]b | the byte offset of the first NAMEd group capture that matched; requires option -P and capturing pattern (?<NAME>PATTERN) |
%[NAME1|NAME2|...]e | the ending byte offset of the first NAMEd group capture that matched; requires option -P and capturing pattern (?<NAME>PATTERN) |
%[NAME1|NAME2|...]d | the byte length of the first NAMEd group capture 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>%~'
If you found a bug or an issue, then please report it at https://github.com/Genivia/ugrep/issues
Ugrep is written by Robert A. van Engelen: https://github.com/Genivia/ugrep copyright (c) 2023 Robert A. van Engelen, Genivia Inc.
The ugrep author received the 🏆 Google Peer Bonus Award 2022 for developing ugrep
Ugrep uses the RE/flex regex library: https://github.com/Genivia/RE-flex
Ugrep -P uses the PCRE2 library: https://www.pcre.org
Ugrep is open source: BSD-3 license
Permissions |
---|
✔️ commercial use |
✔️ modification |
✔️ distribution |
✔️ private use |
Limitations |
---|
❌ liability |
❌ warranty |
Conditions |
---|
ⓘ include license |
ⓘ copyright notice |
See also: gnu grep, bsd grep, git grep, pcre grep, ack, ag, rg, sift
Last updated: Fri Dec 8, 2023