LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

rgrep

Recursive grep through directories

TLDR

Search recursively
$ rgrep "[pattern]" [path]
copy
Case insensitive
$ rgrep -i "[pattern]" [path]
copy
Show line numbers
$ rgrep -n "[pattern]" [path]
copy
List matching files only
$ rgrep -l "[pattern]" [path]
copy
Count matches
$ rgrep -c "[pattern]" [path]
copy
Exclude directory
$ rgrep --exclude-dir=[node_modules] "[pattern]" [path]
copy

SYNOPSIS

rgrep [-i] [-n] [-l] [options] pattern [path]

DESCRIPTION

rgrep is a convenience wrapper equivalent to grep -r, providing recursive text searching through directory trees. It traverses all subdirectories from the specified path, searching file contents for the given pattern using standard grep regular expression syntax.All standard grep options work with rgrep, including case-insensitive search (-i), line numbers (-n), listing matching files only (-l), and inverted matching (-v). The --exclude-dir and --include flags allow filtering which files and directories are searched, which is important for skipping large directories like node_modules or build output.On most GNU/Linux systems, rgrep is installed by default as part of the GNU grep package. For better performance on large codebases, consider using ripgrep (rg) which is significantly faster and automatically respects .gitignore rules.

PARAMETERS

-i

Case insensitive search.
-n
Show line numbers.
-l
Print only names of files with matches.
-c
Print only a count of matching lines per file.
-v
Invert match (select non-matching lines).
-w
Match whole words only.
-E
Use extended regular expressions (same as egrep).
-P
Use Perl-compatible regular expressions.
--color WHEN
Colorize matches: auto, always, or never.
--exclude-dir DIR
Skip directory.
--include GLOB
Search only files matching pattern.
--exclude GLOB
Skip files matching pattern.

INSTALL

sudo apt install grep
copy
sudo dnf install grep
copy
sudo pacman -S grep
copy
sudo zypper install grep
copy
brew install grep
copy

CAVEATS

By default follows symlinks on the command line. May be slow on large trees. Deprecated in GNU grep in favor of grep -r, but still provided for backward compatibility. Consider ripgrep (rg) for better performance on large codebases.

SEE ALSO

grep(1), egrep(1), fgrep(1), rg(1)

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid