Forrest logo
back to the rg tool

rg:tldr:37f82

rg: Only list matched files (useful when piping to other commands).
$ rg --files-with-matches ${regular_expression}
try on your machine

The command "rg --files-with-matches ${regular_expression}" is used to search for files in a directory that contain a specific regular expression pattern. Here is an explanation of each part of the command:

  • "rg": This is the command-line utility "ripgrep" (or "rg" for short) used for searching files.

  • "--files-with-matches": This option tells "rg" to only output the names of files that contain matches for the specified regular expression.

  • "${regular_expression}": This is a placeholder for the actual regular expression pattern that you want to search for. You need to replace "${regular_expression}" with your desired regular expression.

By running this command, "rg" will recursively search for files in the current directory (and subdirectories) and display the names of the files that contain matches for the provided regular expression. It's a handy way to quickly identify files that match a specific pattern without displaying the actual matches.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the rg tool