Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add filename-only option #103

Closed
ddrcoder opened this issue Sep 26, 2016 · 8 comments
Closed

Add filename-only option #103

ddrcoder opened this issue Sep 26, 2016 · 8 comments

Comments

@ddrcoder
Copy link

I quite frequently use grep -l to simply identify files which contained any match of the given pattern. Since only existence checking is required, you could terminate at the first match. The list of files can then be fed to xargs or the like. This would go hand-in-hand with the -0, --null option.

@BurntSushi
Copy link
Owner

This is already done. It's in 0.2.0.

@Flaque
Copy link

Flaque commented Aug 17, 2018

To be clear for folks who stumbled upon this like I did, the way to only show filenames in rg is the same as in grep:

$ rg -l 

@watsoncj
Copy link

Here's the relevant help section from ripgrep 12.1.0:

    -l, --files-with-matches
            Only print the paths with at least one match.

            This overrides --files-without-match.

@iburunat
Copy link

Maybe helpful to know that adding the flag -c/--counter will show the number of lines matching the searched term. The flag --count-matches will count the number of matches instead (see man page).

@NetMage
Copy link

NetMage commented Jan 19, 2021

I think the help could be a little clearer - it doesn't clearly imply that the matches won't be printed.

@SoftwareApe
Copy link

I agree with @NetMage I looked through all the file related options in the help and this one didn't seem to apply.

Only print the paths with at least one match.

To me this says that it will only print those files that have at least one match. Which sounds like the default behavior. It doesn't say that it doesn't print the match, which is what most people are likely looking for.

I think it would be more clear if the help read

Only print the path to the files with matches, not the matches.

@NightMachinery
Copy link

To be clear for folks who stumbled upon this like I did, the way to only show filenames in rg is the same as in grep:

$ rg -l 

rg -l ., to just list everything.

@RichardBronosky
Copy link

Thank you for this! I used it to make vg, the perfect companion to rg.

function vg() { $EDITOR $(rg -l "$@"); }

Then I can follow up "find all files containing pattern" with "edit them".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants