Questions tagged [ripgrep]

ripgrep is a line-oriented search tool that recursively searches your current directory for a regex pattern while respecting your gitignore rules. Also: rg

ripgrep is a line-oriented search tool that recursively searches your current directory for a regex pattern while respecting your gitignore rules.

ripgrep is similar to other popular search tools like The Silver Searcher, ack and grep.

16 questions
62
votes
1 answer

ripgrep: print only filenames matching pattern

Using ripgrep (rg), can I print only the filenames which match a given pattern? There are two separate things I'm trying to do: Match the pattern to the pathname itself (like ag -g pattern) Match the pattern to the contents of the file and print…
Tom Hale
  • 28,728
  • 32
  • 139
  • 229
22
votes
1 answer

How can I search a specific list of files with ripgrep?

I've got a list of files that I would like to search for a pattern with ripgrep. How can this be done?
Chris Stryczynski
  • 5,178
  • 5
  • 40
  • 80
16
votes
1 answer

How is ripgrep different from silver searcher ag?

Are these related? Which is faster? Can either be limited to directory-names? https://github.com/BurntSushi/ripgrep https://github.com/ggreer/the_silver_searcher
johny why
  • 351
  • 1
  • 3
  • 10
9
votes
2 answers

ripgrep path pattern

I'd like ripgrep to search paths with the specified pattern. For e.g. rg PATTERN --path REGEX where PATTERN is the pattern to grep and REGEX is the path matching pattern. I have scattered through the documentation and I am unsure if this…
p0lAris
  • 193
  • 1
  • 4
7
votes
3 answers

How to match a literal string containing an unclosed quote with ripgrep?

I have a file that contains the some python code. There is a line that contains the following(including the quotes) 'hello "value"' I want to search 'hello "value" in the file. Notice the unclosed quote. I'm using ripgrep with the folowing…
Haris Muzaffar
  • 249
  • 2
  • 6
3
votes
0 answers

How does pattern matching work in grep for accented characters (eg. á, è, ò)

What characters match the following regex : ^[a-zA-Z]$ Specifically, should characters with accents (eg. á, è, ò) match this regex? Or just 26 lower and upper case alphabets? I have tried to check this in an online regex, and accented characters…
adiSuper94
  • 31
  • 3
3
votes
5 answers

Recursive grep matching only specific line number

How can I can I find files that contain a specific pattern on a specific line number ? Let's assume I have a directory with a bunch of text files containing 3 lines, such as: Title A Category X Description Y How can I grep / filter every files that…
Pierre-Jean
  • 2,229
  • 1
  • 15
  • 18
2
votes
1 answer

to search for files with 2 (full or partial) keywords content (txt files) in a folder and sub folder and files with specific filename

I just want to share this, and hoping will get more similar tool. I got a directory of text files.. i need to search for the files with 2 (partial) words in it.. the keywords are in random order, but on a same line. So far, i can use this: $ rg -i…
andrew_ysk
  • 155
  • 5
1
vote
2 answers

How can I search only git tracked files with a specific file extension?

I'd like to search all git tracked files that 1. has an .hs file extension and 2. contain the word import in any lines. I've tried to use git ls-files -z | xargs -0 rg -g '*.hs' "import" however unfortunately if you pass an explicit list of files to…
Chris Stryczynski
  • 5,178
  • 5
  • 40
  • 80
1
vote
1 answer

How to use stdin to give data to rankmirrors command

Probably a rooky question, but I have seen that the "rankmirrors" command can use the stdin input. But when I run the following command (which retrieve all URL in use in the "mirrorslist" file to the "rankmirrors"), I get an error: $ rg -e "^Server"…
Apitronix
  • 113
  • 3
1
vote
2 answers

using ripgrep to find adjacent word

How to use ripgrep to find adjacent duplicated words. for example one hello hello world How to locate hello hello by using ripgrep? Solved rg '(hello)[[:blank:]]+\1' --pcre2 <<<'one hello hello world'
jian
  • 539
  • 3
  • 15
1
vote
2 answers

How to individually process each path from a list of paths output from ripgrep

I'm on Linux Ubuntu 18.04 and 20.04. Ripgrep (rg) can output a list of paths to files containing matches like this: # search only .txt files rg 'my pattern to match' -g '*.txt' -l # long form rg 'my pattern to match' --glob '*.txt'…
Gabriel Staples
  • 2,192
  • 1
  • 24
  • 31
1
vote
4 answers

Replace (one or) two different patterns in a file with regexp

Suppose an input.txt file that contains several strings as the following ones: [[foo>a|a]] [[foo>b|b]] [[foo>c|c]] that I'd like to replace by: :foo:`a` :foo:`b` :foo:`c` I guess I could manage to achieve this result with sed or rg (I never used…
Denis Bitouzé
  • 299
  • 1
  • 9
0
votes
2 answers

List files where searched term occurs more than a Threshold

I have a command like rga --files-with-matches --count-matches --sort path -i -e "use cases?" -e "user stor(y|ies)" -e "Technical debt" -e "Code Quality" -e "software development" -e "Agile Manifesto" The output is…
Ahmad Ismail
  • 2,478
  • 1
  • 22
  • 47
0
votes
1 answer

How to I properly set the advanced FZF_DEFAULT_COMMAND environment variable to get it working properly with ohmyz.sh with fzf plugin installed?

I'm new to z shell and ohmyz.sh. I have the following in my zshrc to integrate fzf with rg. This is exactly how it appears in the fzf…
StevieD
  • 855
  • 2
  • 10
  • 23
1
2