NIMGREP(1) User Commands NIMGREP(1)

nimgrep - Nimgrep

nimgrep - Nim Grep Searching and Replacement Utility Version 2.0.0

(c) 2012-2020 Andreas Rumpf

Usage:

* To search:

nimgrep [options] PATTERN [(FILE/DIRECTORY)*/-]

* To replace:

nimgrep [options] PATTERN --replace REPLACEMENT (FILE/DIRECTORY)*/-

* To list file names:

nimgrep [options] --filenames [PATTERN] [(FILE/DIRECTORY)*]

Positional arguments, from left to right: 1) PATTERN is either Regex (default) or Peg if `--peg` is specified.

PATTERN and REPLACEMENT should be skipped when `--stdin` is specified.

2) REPLACEMENT supports `$1`, `$#` notations for captured groups in PATTERN.

.. DANGER:: `--replace` mode **DOES NOT** ask confirmation
unless `--confirm` is specified!

3) Final arguments are a list of paths (FILE/DIRECTORY) or a standalone

minus `-` or not specified (empty):
* empty, current directory `.` is assumed (not with `--replace`)
.. Note:: so when no FILE/DIRECTORY/`-` is specified nimgrep
does **not** read the pipe, but searches files in the current dir instead!
* `-`, read buffer once from stdin: pipe or terminal input;
in `--replace` mode the result is directed to stdout; it's not compatible with `--stdin`, `--filenames`, or `--confirm`
For any given DIRECTORY nimgrep searches only its immediate files without traversing subdirectories unless `--recursive` is specified.

In replacement mode we require all 3 positional arguments to avoid damaging.

find the PATTERN (default)
replace the PATTERN to REPLACEMENT, rewriting the files
confirm each occurrence/replacement; there is a chance to abort any time without touching the file
just list filenames. Provide a PATTERN to find it in the filenames (not in the contents of a file) or run with empty pattern to just list all files:
# In current dir
# Note empty pattern "", lists all files in DIRECTORY

PATTERN and PAT are Peg
PATTERN and PAT are regular expressions (default)
use the "extended" syntax for the regular expression so that whitespace is not significant
matches should have word boundaries (buggy for pegs!)
be case-insensitive in PATTERN and PAT
be style insensitive in PATTERN and PAT
.. Note:: PATTERN and patterns PAT (see below in other options) are all either
Regex or Peg simultaneously and options `--rex`, `--word`, `--ignoreCase`, and `--ignoreStyle` are applied to all of them.

process directories recursively
follow all symlinks when processing recursively
order files by the last modification time (default: off): ascending (recent files go last) or descending

* Filter files (based on filesystem paths):

.. Hint:: Instead of `not` you can type just `n` for negative options below.
only search the files with the given extension(s), empty one (`--ex`) means files with missing extension
exclude files having given extension(s), use empty one to skip files with no extension (like some binary files are)
search only files whose name matches pattern PAT
skip files whose name matches pattern PAT
select files that in their path have a directory name that matches pattern PAT
do not descend into directories whose name (not path) matches pattern PAT
select only files whose whole relative directory path matches pattern PAT
skip files whose whole relative directory path matches pattern PAT

select files containing a (not displayed) match of PAT
skip files containing a match of PAT
process binary files? (detected by \0 in first 1K bytes) (default: on - binary and text files treated the same way)
process only text files, the same as `--bin:off`

select only matches containing a match of PAT in their surrounding context (multiline with `-c`, `-a`, `-b`)
skip matches not containing a match of PAT in their surrounding context

output will be given without any colors
force color even if output is redirected (default: auto)
select color THEME from `simple` (default), `bnw` (black and white), `ack`, or `gnu` (GNU grep)
only print counts of matches for files that matched
print N lines of leading context before every match and N lines of trailing context after it (default N: 0)
print N lines of trailing context after every match
print N lines of leading context before every match
group matches by file
display every matching line starting from a new line
limit max displayed columns/width of output lines from files by N characters, cropping overflows (default: off)
calculate columns from terminal width for every line
display only printable ASCII Latin characters 0x20-0x7E substitutions: 0 -> ^@, 1 -> ^A, ... 0x1F -> ^_,
0x7F -> '7F, ..., 0xFF -> 'FF

speed up search by N additional workers (default: 0, off)
read PATTERN from stdin (to avoid the shell's confusing quoting rules) and, if `--replace` given, REPLACEMENT
be verbose: list every processed file
shows this help
shows the version
February 2026 nimgrep 2.2.8