Questions tagged [ripgrep]

ripgrep (rg) is a line-oriented search tool, similar to grep or ack, that recursively searches your current directory for a regex pattern. Use this tag for questions about using ripgrep.

ripgrep is a line-oriented search tool that recursively searches your current directory for a regex pattern. By default, ripgrep will respect your .gitignore and automatically skip hidden files/directories and binary files. ripgrep has first class support on Windows, macOS and Linux, with binary downloads available for every release. ripgrep is similar to other popular search tools like The Silver Searcher, ack and grep.

User Guide

58 questions
1
vote
2 answers

Finding the distinct directory names using grep or rg

I am new to Linux commands and I am trying to search for a word that say "apple" recursively in a directory and all the directory names that contain the word. I am using ripgrep(rg) similar to grep to get the file names that have an apple in…
Red Gundu
  • 183
  • 2
  • 10
1
vote
1 answer

Regex if then without else in ripgrep

I am trying to match some methods in a bunch of python scripts if certain conditions are met. First thing i am looking at is if import re exists in a file, and if it does, then find all cases of re.sub(something). I tried following the documentation…
securisec
  • 3,435
  • 6
  • 36
  • 63
0
votes
2 answers

Behaviour of Bash command changes in $()

When running Ripgrep normally in Bash, the output is formatted as follows: $ rg asdfghjkl my_file 1:asdfghjkl But if I attempt to capture the output with $(), the format is different: $ foo=$(rg asdfghjkl) $ echo "$foo" my_file:asdfghjkl What…
Alira
  • 55
  • 1
  • 6
0
votes
1 answer

How to install ripgrep on Windows?

How do I install ripgrep (rg) on Windows?
Gabriel Staples
  • 36,492
  • 15
  • 194
  • 265
0
votes
1 answer

Show total count of matches

I run rg "\bres\b" --stats on my code and it shows be such stats: 665 matches 534 matched lines 149 files contained matches 3603 files searched 33871 bytes printed 9805953 bytes searched 0.445034 seconds spent searching 0.083803 seconds I only want…
Max Smirnov
  • 477
  • 3
  • 10
0
votes
0 answers

shell script is not same as single line grep command

I have this shell script that works as expected. #!/bin/sh for ID in `cat comment_g.txt` do rg -w $ID wordsuc.txt >> out.txt done But the following grep command does not return a single record. rg -w -f comment_g.txt wordsuc.txt > out2.txt Isn't…
shantanuo
  • 31,689
  • 78
  • 245
  • 403
0
votes
0 answers

How can I resolve a compilation error when using a git dependency in Cargo with Rust?

I am facing a compilation error after switching one of my dependencies from cargo.io to a GitHub using Cargo. I would appreciate your assistance in resolving this issue. Details: Language: Rust Package manager: Cargo Source Code:…
0
votes
1 answer

Wrong line numbers reported when using multiline search

Given the following text: defmodule MyModule do app_env(:plans, :myapp, [:billing, :plans], binding_order: [:config], required: true, type: :any ) app_env( :plans_with_min_amount_of_integrations, :myapp, [:billing,…
oldhomemovie
  • 14,621
  • 13
  • 64
  • 99
0
votes
1 answer

How to use alternation operator in Vim + RipGrep?

I have the following in my .vimrc which (I believe) makes :grep within Vim use rg: if executable('rg') set grepprg=rg\ --no-heading\ --vimgrep\ --hidden\ --case-sensitive\ --ignore-vcs\ --glob\ '!.git'\ --glob\ '!node_modules' endif I want to…
Aaron Parisi
  • 464
  • 7
  • 15
0
votes
1 answer

macos emacs (file-missing "Cannot open load file" "No such file or directory" "rg"

I'm trying to install ripgrep in emacs in order to use it with hledger-mode I added this lines to my ~/.emacs.d/init.el: (require 'rg) (rg-enable-default-bindings) And running emacs -nw --debug-init shows me this: Debugger entered--Lisp error:…
0
votes
1 answer

How do I remove Library and Music from searching with Ripgrep and FZF?

I'm trying to configure rg and fzf on my mac, but really cannot work out how to clear out lots of annoying files from search. I have a ~/.gitignore with the following: Library/* Music/* (and I also tried without the '*' at the end of the line) and…
Raph117
  • 3,441
  • 7
  • 29
  • 50
0
votes
0 answers

list all imports recursively from a file

I am reorganising a react codebase and I would like to write a bash script which I can give a path to a component which lists all the files imported from that file recursively. The output should be filtered by unique occurrences. I am only…
Andreas Bolz
  • 191
  • 13
0
votes
1 answer

piping zsh functions to another shell command

I'm trying to apply this approach in a more generic way. I adopted the code in ~/.zshrc as follows: 27 │ irg() { 28 │ RG_PREFIX="rg --column --line-number --no-heading --color=always --smart-case " 29 │ INITIAL_QUERY="${*:-}" 30 ~…
v8vb
  • 49
  • 9
0
votes
0 answers

Why is any config file for ripgrep excluded using the --no-config flag in vscode?

In src\vs\workbench\services\search\node\ripgrepFileSearch.ts:74 there is a command line flag for ripgrep to exclude any defined config files for ripgrep args.push('--no-config'); Why is that there? What is the reasoning behind not respecting any…
0
votes
1 answer

Exclude match if string is prefaced with another string

I have a feeling this will get closed as a duplicate as it seems like this would be a common ask...but in my defense, I have searched SO as well as Google and could not find anything. I'm trying to search SQL files using ripgrep, but I want to…
Chad Baldwin
  • 2,239
  • 18
  • 32