Command: xgrep

  XGREP is a program for searching text files based on the UNIX utility
  GREP. You can use XGREP to:
    - display the lines in a file that contain a particular word,
      phrase or pattern;
    - count those lines in which a particular pattern occurs; or
      generate a list of files that refer to a given topic.

Syntax:

  xgrep [-chlnsvyorx] expression [files]
  xgrep [/chlnsvyorx] expression [files]
        expression  the expression to search, may also be classes.
  xgrep -h  Shows the help.

Options:

  -c  Line count only.
  -h  No file names.
  -l  File names only.
  -n  Number of lines.
  -o  Errors to stdout - error messages will be redirected along with
      standard output.
  -r  Recursively search subdirectories - looks for files not only in
      the specified directory but in all the subdirectories of that
      directory.
  -s  Silent about inaccessible files.
  -v  Non-matching lines - "inverts" the result of any match.
  -x  No magic: all operators need '\'. The -x option causes the
      ordinarily "special" characters: . [ * + ? ^ $ to be parsed, by
      default, as literals. For example, the following commands are
      equivalent:
        xgrep    "p\[0] \* 3" test.c
        xgrep -x "p[0] * 3"   test.c
      All regular expression operators are still accessible, but must
      be preceded by a \ (backslash).
  -y  Case-insensitive match - matching is not case-sensitive.
  Two further options are supported as aliases for other options:
  -d  is an alias for -r.
  -i  is an alias for -y.

Comments:

  Like GREP, XGREP works best on plain text files: the sort of files
  that do not contain binary data or non-ASCII control characters, and
  which are divided into lines or records ending in a '\n' (newline).
  XGREP supports text files in both UNIX (LF) and MS-DOS (CR, LF)
  formats.
  In XGREP, the : (colon) may be used to refer to predefined classes.
  The twelve predefined classes, together with their definitions, are as
  follows:
    ID  Name   Description  Class          ASCII ranges:
    :a  alpha  alphabetic   [A-Za-z]       65-90,97-122
    :c  cntrl  control                     0-31,127
    :d  digit  digits       [0-9]          48-57
    :g  graph  graphics     [!-˜]          33-126
    :l  lower  lowercase    [a-z]          97-122
    :n  alnum  alphanumeric [0-9A-Za-z]    48-57,65-90,97-122
    :p  punct  punctuation  [!-/:-@[-`{-˜] 33-47,58-64,91-96, 123-126
    :s  space  whitespace                  9-13,32
    :t  print  printable    [ -˜]          32-126
    :u  upper  uppercase    [A-Z]          65-90
    :x  xdigit hex digits   [0-9A-Fa-f]    48-57,65-70,97-102
    :z  ascii                              0-127

  Signs to specify the context:
    ^    Start of line
    $    End of line
    .    Wildcard
    []   Character class
    [^]  Inverse Class
    \    Quote next character
  Repeat:
    *        0 or more times
    +        1 or more times
    ?        0 or 1 times
    \{m\}    m times
    \{m,\}   m or more times
    \{m,u\}  m to u times
  For more information about ":" and "signs to specify the context"
  please read XGREP.DOC.
  XGREP has the following EXITCODES (ERRORLEVEL):
    0  At least one match found.
    1  No matches found.
    2  Error(s) occurred.
  For more information about XGREP see:
  https://www.ibiblio.org/pub/micro/pc-stuff/freedos/util/unix
  xgrep  OR:
  https://gitlab.com/FreeDOS/unix/xgrep/-/blob/master/DOC/XGREP/
  XGREP.DOC OR:
  C:\FREEDOS\DOC\XGREP\xgrep.doc

Examples:

  xgrep "Hello World" *.c
  xgrep -c jill group
  xgrep -l SCSI *.doc

  xgrep widgets
  xgrep -n widgets notes.txt
  xgrep -n -rs widgets \*.txt \*.doc

See also:

  find
  gnugrep

  Copyright © 1994 Robert Nordier, help version 2023 W. Spiegl.

  This file is derived from the FreeDOS Spec Command HOWTO.
  See the file H2Cpying for copying conditions.