Questions tagged [grep]

75 questions
22
votes
5 answers

How to recursively search / grep file contents in a directory / subdirectories in Emacs?

I'm using Emacs for quite some time and I still somehow fail to understand what is the best way to (recursively) grep for a string within a (project) directory and get the results presented either as a dired buffer or in some even more useful way.…
Boris Stitnicky
  • 573
  • 2
  • 5
  • 10
10
votes
3 answers

Is it possible to remove matches manually in grep mode?

After running (grep) the grep buffer appears with matches. Some of the matches are not relevant, and it would be good to remove them manually. This way I can use the grep buffer to hold only those matches which are relevant to the current…
cammil
  • 509
  • 3
  • 12
6
votes
1 answer

rgrep : visiting matches without switching buffer

I was wondering if there is a way to visit the matches listed in the grep buffer without actually switching to the match buffer, similarly to C-o with Occur.
Stefano
  • 91
  • 3
5
votes
1 answer

Search files by content using full boolean expressions

Suppose I want to find all *tex files recursively from a given directory containing foo and bar but not doe. I am looking for something like helm-do-ag, but that doesn't seem to support the not operator. So is there anything like that which supports…
student
  • 1,099
  • 9
  • 29
4
votes
4 answers

Grep pipe support and how to filter grep results

I try to filter the output of M-x grep with grep --color=always -nH -e "text_to_find" ~/path/to/files/*.org | grep -v "text_to_ignore" but it doesn't seem to be working. The 'to be ignored' part is still not filtered away. Is it true that grep in…
Sati
  • 775
  • 6
  • 23
4
votes
2 answers

Read find-grep exclusion patterns from a .findignore file

I am aware that you can customise the "find" command executed when using "find-grep" with "setq grep-find-command" and define which file-patterns to ignore in the search. I would like to take this further and be able to read the patterns to ignore…
krystalcode
  • 219
  • 1
  • 7
3
votes
2 answers

Unable to visit file from grep results

I recently updated to emacs 26.1. Since then, grep results are not highlighted and does not contain links to files. 'n' or 'p' gives "Moved past last grep hit" or "Moved back before first grep hit". Steps followed: 1. Ran emacs 26.1 with -Q…
Aravind
  • 31
  • 3
2
votes
1 answer

Case insensitive search with M-x find-grep-dired

I’m trying to do a case insensitive search with M-x find-grep-dired. When I enter M-x find-grep-dired and hit ENTER and enter the directory name I get the prompt find-grep (grep regexp):. I understand this as “enter grep and then regexp”. So, for…
zeynel
  • 371
  • 1
  • 11
1
vote
1 answer

Is there a way to narrow down grep results?

When I search with grep, I get the results like: -- mode: grep; default-directory: "~/code/" -- Grep started at Wed Feb 24 12:40:28 find . -type d ... that is followed by multiple lines with results. Now when I have the result, how do I narrow the…
ruby_object
  • 437
  • 2
  • 12
1
vote
0 answers

`find-grep` (aka `grep-find`) not finding a line when in an upper directory

[Top-posting an update] Results of deeper inquiry, after filing a bug report. It appears that the failure is related to a recent update to the cygwin environment. Where previously the single-quoted parameter '*.log' to the -name option to find was…
1
vote
1 answer

grep view limit line lengths

When I grep inside emacs, it begins to be completelly laggy when lines are too long (just try to grep in your home emacs directory and you will see what I mean). How to set limit to line lengths in grep output buffer? The effect can be reproduced…
dev1223
  • 241
  • 1
  • 10
0
votes
1 answer

using grep on a specific file

I've read, for instance here, that one could just run M-x grep to interface with the underlying shell and just run a simple grep command. I suspect something is wrong in the setup because this simple command does not work. Here's what I can…
Mike Anblips
  • 668
  • 6
  • 20
0
votes
1 answer

Run grep (like this)

I use the standard grep command a lot. When I execute it, the minibuffer is populated with the following the text, allowing me to complete the command: Run grep (like this): grep --color -nH --null -e I almost always prefer to use Perl regex and…
ch-pub
  • 220
  • 1
  • 10
0
votes
1 answer

wgrep for special multiline grep (pcregrep)

wgrep works well for every line in context search like grep -C 2. It also works for grepmail, special grep-like program for mailboxes. You can edit each line of output. How to force pcregrep with multiline request like ^[ \t]+-.*\n +CLOCK to…
artscan
  • 445
  • 3
  • 12