a more capable compatible grep replacement -- search for anything in everything... fast!
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
emerge sys-apps/ugrep
pkg_add ugrep
zypper install ugrep
dnf install ugrep
apt-get 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
fast and reliable
Why use ugrep?
Search fast with enhanced grep command options and with the built-in TUI (shown). Google search files with logic patterns (shown), fuzzy search, search (nested!) zip/7z/tar/pax/cpio archives, tarballs and compressed files gz/Z/bz/bz2/lzma/xz/lz4/zstd/brotli, search and hexdump binary files, and search documents, such as PDF, doc, docx. Output results like grep or in JSON, XML, CSV or your own customized format. Offers rich Unicode extended regex pattern syntax, PCRE regex syntax, and multi-line pattern matching without requiring any special 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)Also...
egrep, but supporting full Unicode matching by default
ugrep to grep, egrep, fgrep, zgrep, zegrap, zfgrep to a directory on your PATH; ugrep automatically emulates these grep executables according to these names; important: copy ugrep instead of symlink when using bash as a shell!
Ugrep is compatible with GNU/BSD grep command-line options to lower the learning curve when using ugrep as a replacement. But ugrep offers many new options and featues. 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.
Also...
fgrep or grep -F
grep or grep -G
Also...
Also...
Also...
ugrep is installed as replacement binaries for GNU/BSD grep, egrep fgrep, zgrep, zegrep or zfgrep, option -Z is automatically reassigned to --null for GNU/BSD grep compatibility; use grep --fuzzy instead for fuzzy search
Also...
ug always search archives and compressed files, add decompress to your ~/.ugrep file
ugrep is installed as replacement binaries for GNU/BSD grep, egrep fgrep, zgrep, zegrep or zfgrep, option -z is automatically reassigned to --null-data for GNU/BSD grep compatibility; use zgrep, zegrep, zfgrep instead
Also...
Also...
Also...
Also...
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 |
| a(b|cd?) | ab or ac or acd |
| \. | 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 |
| (?#...) | comments ... are ignored |
| (...) | group |
| patterns that require option -P | |
|---|---|
| (...) | capturing group |
| (?:...) | non-capturing group |
| (?=...) | lookahead |
| (?!...) | negative lookahead |
| (?<=...) | lookbehind |
| (?<!...) | negative lookbehind |
| (?<X>...) | capturing group name X |
| \3 | matches group 3 |
| \g{10} | matches group 10 |
| \g{X} | matches group name X |
egrep or grep -E
| 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 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| adoc | = | -O adoc | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 | seed7 | = | -O sd7,s7i | 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". When a filename extension matches a specified filter filename extension ext, then the filter command is executed on the file and the command output is searched instead of the file. Arguments to the specified command may be included and seperated by space. The special command argument % is expanded into the pathname of the file. A command should read the file given by the expanded pathname argument or read the file that is opened as standard input to the command. A wildcard * matches any extension that is not matched by any of the ext specified (matching is case sensitive). 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. To produce custom output, specify option --format="FORMAT" with text and the following format fields:
| %% | % |
| %~ | newline (LF or CRLF) |
| %a | basename of matching file |
| %A | byte range in hex of a match |
| %b | byte offset of a match |
| %B %[...]B | text ... + byte offset, if -b |
| %c | matching pattern as C/C++ |
| %C | matching line as C/C++ |
| %d | byte size of a match |
| %e | end offset of a match |
| %f | pathname of matching file |
| %F %[...]F | text ... + pathname, if -H |
| %+ | %F as heading/break, if -+ |
| %h | quoted "pathname" |
| %H %[...]H | text ... + "pathname", if -H |
| %i | pathname as XML |
| %I %[...]I | text ... + pathname XML, if -H |
| %j | matching pattern as JSON |
| %J | matching line as JSON |
| %k | column number of a match |
| %K %[...]K | text ... + column number, if -k |
| %l | last line number of a match |
| %L | number of lines of a match |
| %m | number of matches |
| %M | number of matching lines |
| %n | line number of a match |
| %N %[...]N | text ... + line number, if -n |
| %o | matching pattern, also %0 |
| %O | matching line |
| %p | path to matching file |
| %q | quoted matching pattern |
| %Q | quoted matching line |
| %R | newline, if --break |
| %s | separator (: by default) |
| %S %[...]S | text ... + separator, if %m > 1 |
| %t | tab |
| %T %[...]T | text ... + tab, if -T |
| %u | unique lines, unless -u |
| %[hhhh]U | U+hhhh Unicode code point |
| %v | matching pattern as CSV |
| %V | matching line as CSV |
| %w | match width in wide chars |
| %x | matching pattern as XML |
| %X | matching line as XML |
| %y | matching pattern as hex |
| %Y | matching line as hex |
| %z | path in archive |
| %Z | edit distance cost, if -Z |
| %[...]< | text ... if %m = 1 |
| %[...]> | text ... if %m > 1 |
| %, | , if %m > 1, same as %[,]> |
| %: | : if %m > 1, same as %[:]> |
| %; | ; if %m > 1, same as %[;]> |
| %| | | if %m > 1, same as %[|]> |
| %[...]$ | assign text ... to separator |
| %$ | reset to default separator |
| %[ms]=...%= | color of ms ... color off |
| fields that require option -P for captures | |
|---|---|
| %1 %2 %3 ... %9 | group capture |
| %[n]# | nth group capture |
| %[n]b | nth capture byte offset |
| %[n]d | nth capture byte size |
| %[n]e | nth capture end offset |
| %[n]j | nth capture as JSON |
| %[n]q | nth capture quoted |
| %[n]v | nth capture as CSV |
| %[n]x | nth capture as XML |
| %[n]y | nth capture as hex |
| %[name]# | named group capture |
| %[name]b | named capture byte offset |
| %[name]d | named capture byte size |
| %[name]e | named capture end offset |
| %[name]j | named capture as JSON |
| %[name]q | named capture quoted |
| %[name]v | named capture as CSV |
| %[name]x | named capture as XML |
| %[name]y | named capture as hex |
| %[n|...]# | capture n,... that matched |
| %[n|...]b | capture n,... byte offset |
| %[n|...]d | capture n,... byte size |
| %[n|...]e | capture n,... end offset |
| %[n|...]j | capture n,... as JSON |
| %[n|...]q | capture n,... quoted |
| %[n|...]v | capture n,... as CSV |
| %[n|...]x | capture n,... as XML |
| %[n|...]y | capture n,... as hex |
| %g | capture number or name |
| %G | all capture numbers/names |
| %[t|...]g | text t,... indexed by capture |
| %[t|...]G | all t,... indexed by captures |
Table of all options that accept format fields:
| --format-begin="FORMAT" | format for beginning the search |
| --format-open="FORMAT" | format for opening a file when a match was found |
| --format="FORMAT" | format for each match in a file |
| --format-close="FORMAT" | format for closing a file when a match was found |
| --format-end="FORMAT" | format for ending the search |
| --replace="FORMAT" | replace matches in the output with the specified format |
--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="]I>%~' --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.