jrep(1)

NAME
jrep - grep-like utility written in Java

SYNOPSIS
jrep [OPTIONS] PATTERN [FILES...]

DESCRIPTION
jrep searches for PATTERN in each FILE or standard input. PATTERN is, by default, a Java regular expression (java.lang.regex).

When FILE is -, read standard input. With no FILE, read . if a command-line -r is given, - otherwise. If fewer than two FILEs are given, assume -h. Exit status is 0 if any line is selected, 1 otherwise; if any error occurs and -q is not given, the exit status is 2.

OPTIONS

  Regexp selection and interpretation

-E,--extended-regexp
    Ignored.

-F,--fixed-strings
    Interpret pattern as a set of fixed strings.

-G,--basic-regexp
    Ignored.

-P,--perl-regexp
    Ignored.

-2  Same as '--re-engine re2j'.

--re-engine ENGINE
    Specify a RE engine. ENGINE is either 'java' (java.util.regex) or 're2j' (com.google.re2j). The default is 'java'.

-e,--regexp PATTERN
    Specify a pattern used during the search of the input: an input line is selected if it matches any of the specified patterns. This option is most useful when multiple -e options are used to specify multiple patterns, or when a pattern begins with a dash ('-').

-f,--file FILE
    Obtain PATTERN from FILE.

-i,--ignore-case
    Perform case insensitive matching. By default, jrep is case sensitive.

-w,--word-regexp
    Force PATTERN to match only whole words.

-x,--line-regexp
    Only input lines selected against an entire fixed string or regular expression are considered to be matching lines.

  Miscellaneous:

-s,--no-messages
    Suppress error messages

-v,--invert-match
    Selected lines are those not matching any of the specified patterns.

-V,--version
    Display version information and exit.

--help
    Display this help text and exit.

  Output control:

-m,--max-count NUM
    Stop after NUM matches.

-n,--line-number
    Each output line is preceded by its relative line number in the file, starting at line 1. The line number counter is reset for each file processed. This option is ignored if -c, -L, -l, or -q is specified.

--line-buffered
    Flush output on every line.

-H,--with-filename
    Print the file name for each match.

-h,--no-filename
    Never print filename headers (i.e. filenames) with output lines.

--label LABEL
    Use LABEL as the standard input file name prefix.

-o,--only-matching
    Print each match, but only the match, not the entire line.

-O,--output-format FORMAT
    Same as -o but FORMAT specifies the output format. Within format string the symbol $ has a special meaning.

    Doubled $ means the symbol $ itself.

    Sequence $N, where N is a single digit, means group number N. Sequence $f means a filename where match was found. All other characters, not preceeded by $, are output as is. Number N can be surrounded by curly braces, this allows to use a group number more than 9. Sequences $< and $> mean start and end markers respectively (See options --marker-start, --marker-end and JREP_COLOR environment variable). Symbols `f', `<' and '>' can also be surrounded by curly braces.

    Within curly braces the following special modifiers may be used. n for replacing LF (line feed) and backslash characters with '\n' and '\\' sequences respectively. N for replacing LF with ASCII space. s for replacing a sequence of unicode spaces with a single one. t for trimming leading and trailing unicode spaces from the group. b for removing directory from filename. c for CSV quoting string. C same as -c but always surround entry with double quotes. e for removing extension from filename. Modifiers are applied from left to right.

    Examples:
       jrep -h -O '${fb} ${0st}' '^.*BSD.*$' -r /path/to/directory
       jrep -h -O '${fc},${1c},${2C}' '(\S+)=(\S+)' *.txt
       jrep -O 'Do you $<like$> $1$<${2}$>? :-)' '([^\s.]+)(BSD)' *.txt
       jrep -8h -O '${1Nst}' '<b>(.+?)</b>' *.html

--marker-start MARKER
    Marker for the beginning of matched substring.

--marker-end MARKER
    Marker for the end of matched substring.

-q,--quiet
    Quiet. Nothing shall be written to the standard output, regardless of matching lines. Exit with zero status if an input line is selected.

--silent
    Same as --quiet.

-8  Match the whole file content at once.

-d,--directories ACTION
    How to handle directories; ACTION is 'read', 'recurse', or 'skip'.

-r,--recursive
    Like --directories=recurse.

-R,--dereference-recursive
    Same as -r but follow all symbolic links.

--include FILE_PATTERN
    Search only files that match FILE_PATTERN pattern.

--exclude FILE_PATTERN
    Skip files matching FILE_PATTERN.

--exclude-dir DIR_PATTERN
    Exclude directories matching the pattern DIR_PATTERN from recursive searches. This option can be applied multiple times.

--exclude-from FILE
    Skip files matching patterns (one per line) specified in FILE.

-L,--files-without-match
    Only the names of files not containing selected lines are written to standard output. Pathnames are listed once per file searched. If the standard input is searched, the string "(standard input)" is written.

-l,--files-with-matches
    Only the names of files containing selected lines are written to standard output. grep will only search a file until a match has been found, making searches potentially less expensive. Pathnames are listed once per file searched. If the standard input is searched, the string "(standard input)" is written.

-c,--count
    Only a count of selected lines is written to standard output.

  Context control:

-B,--before-context NUM
    Print NUM lines of leading context.

-A,--after-context NUM
    Print NUM lines of trailing context.

-C,--context NUM
    Print NUM lines of output context.

--color WHEN
    Use markers to highlight the matching strings; WHEN is 'always', 'never' or 'auto'. The default is 'auto'.

--colour WHEN
    Same as --color.

EXTENSIONS OVER GNU GREP
Options -O, -8, --re-engine and -2

REGULAR EXPRESSIONS
<https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html>

EXIT STATUS
The exit status is 0 if selected lines are found, and 1 if not found. If an error occurred the exit status is 2.

ENVIRONMENT VARIABLES

JREP_COLOR and GREP_COLOR
    This variable specifies the color used to highlight matched (non-empty) text. It can only specify the color used to highlight the matching non-empty text in any matching line (a selected line when the -v command-line option is omitted, or a context line when -v is specified).

JREP_JAVA
    Path to java. By default 'java'.

JREP_JAVA_OPTS
    Options passed to java(1).

JREP_JNI_DIR
    Directory with jrep_jni library.

JREP_NO_JNI
    If set, jrep_jni library is not loaded. This implies --color=never.

COPYRIGHT
Copyright 2016-2017 Aleksey Cheusov <vle@gmx.net>

HOME
<https://github.com/cheusov/jrep>

SEE ALSO
grep(1)