Questions tagged [grep]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1
vote
2answers
62 views

Efficiently calling multiple variants of the grep command

The context I commonly execute the following variants of the grep command grep --color -RHIn '' (search in the current working directory) grep --color -RHIn --include='*.org' '' ~/repos/dotfiles/...
2
votes
3answers
63 views

emacs grep eliminate suspects

Typically, at the beginning of a coding/maintenance task, I usually start with a carefully worded grep, such as M-x grep git --no-pager grep -n -e 'collect' -- ':!*spec*' ':!*.yml'<enter> and ...
0
votes
0answers
15 views

Moving back to previous cursor position in rg.el

I am using rg(https://github.com/dajva/rg.el) to search in a project. When I click on one of the files rg has found and go to that location I am unable to go back to the previous location. I have ...
3
votes
1answer
66 views

How to keep grep results in eshell buffer

When entering the grep command in an eshell in spacemacs, a separate window and buffer are created to list the grep output results. However, I would prefer for the output to be listed in the eshell ...
0
votes
1answer
39 views

List all empty checkboxes in files

Is there any easy way, including installing a package, to list all waiting checkboxes in all the files in the directory? So far I do the following for the checkboxes in a file: M-x occur - \[ \] ...
0
votes
1answer
60 views

Emacs wsl grep fails on special characters

I'm using GNU Emacs 26.3 on a Windows 10 system (Virtualbox guest on Mac). The following grep command inside emacs fails: grep -i -n -d skip -e temp_ * with this error: grep -i -n -d skip -e temp_ ...
0
votes
0answers
34 views

Grep exited abnormally when using lgrep command

Debian 10, Emacs 26.1 I want to search word "The" for each file in folder test1, by using the command M-x lgrep The [Enter] test1 And the result is zsh:1: no matches found: .[!.]* I ...
1
vote
0answers
32 views

Abort output in currently executing command in shell mode

Sometimes in shell I end up executing a command which results in too much output. For example, consider a wrong grep on a huge text file which results in 10,000 matches. The grep command completes ...
0
votes
1answer
50 views

Automatic “push-mark” when navigating with xref, find-grep, etc?

There seem to be a lot of situations, where a command changes the cursor location (point), but no mark is pushed, making navigating back by popping the mark with C-u SPC impossible. For isolated use-...
2
votes
0answers
27 views

Helm Grep within a first results set / multi line search

I would like to use helm to search for two terms which may well be on different lines. Is there a way to grep for the first term then further grep within the resulting fileset the second term? eg ...
5
votes
0answers
119 views

Sort ripgrep results based on proximity to current buffer

I use counsel-projectile-rg to search within the project I work on. But there is my sub-project inside this big repo that most of my development is in. Is there a way to sort ripgrep results based on ...
0
votes
2answers
52 views

How can I do a regex search recursively from a directory?

Basically I want a command that can do the following: find /path/dir -type f -print0 | xargs -0 grep -l "foo" Is there an emacs command to do this? If not, then is there a convenient keybinding that ...
2
votes
1answer
147 views

How to use `next-error` and `previous-error` without the compilation buffer visible

I want to be able to use grep to find matching lines and to be able to jump through them using next-error and previous-error however I don't feel the need to have the match list on screen and it takes ...
0
votes
0answers
25 views

Using xref-pop-marker-stack with next-error?

When I use xref to jump to the definition of a symbol, I can retrace my steps using M-, (xref-pop-marker-stack). I would like to be able to do the same thing after jumping to results in compilation, ...
2
votes
1answer
77 views

eshell grep thinks options are patterns on windows

I'm using Emacs on windows, and was trying to run grep from within eshell (M-x eshell). The default shell through M-x is cmd.exe, but eshell has linux utilities so I'm trying to use eshell. Now, ...
1
vote
1answer
40 views

Does grepping via helm support searching for multiple words in any order like other helm completions?

When searching multiple terms with Helm separated with spaces then Helm returns the results which mach the terms in any order. This is good. Sometimes I try grep via helm. E.g. I use helm-recentf to ...
4
votes
4answers
610 views

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 ...
0
votes
0answers
74 views

Search in recent files

I use helm-recentf to receive the list of recent files. I would like to have an opportunity to search over the list of recently viewed files. Can I do it with grep or helm-swoop? Is there any other ...
0
votes
1answer
74 views

Cannot jump to file or location link in grep-mode or compile-mode

I have recently installed emacs on a new system (Manjaro arch-linux), using my usual configuration (available here, if relevant). However, the jump function never works on this new system: whenever ...
1
vote
0answers
60 views

How to make `helm-projectile-grep` do a recursive search?

I use helm with projectile and treemacs, how do I make helm-projectile-grep command to search in all project folders recursively starting at the project root. According to this page helm-projectile ...
3
votes
3answers
328 views

How to ignore backup files (~) when running grep?

M-x grep can be used to find strings in files. But I'm not interested in backup files (those whose name ends with a ~). How should I ignore those files when using the grep command?
2
votes
1answer
420 views

Grep exited abnormally with code 2

Windows 10, Emacs 26.1 M-x shell grep here result: grep Usage: grep [OPTION]... PATTERN [FILE]... Try 'grep --help' for more information. Nice. Now I want to find files in temp folder: rgrep ...
3
votes
2answers
276 views

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". ...
3
votes
1answer
129 views

Have compilation errors / grep match reuse current frame/window without ever splitting it?

I have searched in a number of places (1, 2, 3, 4) even looked at the e-lisp source files and could not figure out how to do, so I ask. Context I have bound next-error to a key. I'm in some source ...
4
votes
1answer
329 views

Jump to file and line number in grep file

$ grep -nrH would . | tee file.txt $ emacs file.txt If I have a buffer with grep search results, how can I make Emacs jump to the file and line number on the cursor line, similar to diff-goto-source ...
1
vote
1answer
241 views

color rgrep matching results in the rgrep results buffer

I am liking rgrep as it lets you choose a path and searches recursively. How is it possible to highlight the matches in the rgrep buffer?
1
vote
0answers
39 views

`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 ...
3
votes
1answer
592 views

find-grep-dired: find exited abnormally with code 1

Windows 10, Emacs 25.1, Dired+ I want in Dired to find all files that contain text "UserOptions". M-x find-grep-dired In folder ca UserOptions And here result: find exited abnormally with code 1 ...
1
vote
1answer
141 views

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 ...
5
votes
2answers
2k views

Advanced git grep from within emacs

I've been playing with vc-git-grep as pointed to by this answer How do you grep from within emacs ( git grep 'foo' | grep baa ) I have a special requirement like this: $ git grep -e 'include'...
2
votes
1answer
260 views

How do you grep from within emacs ( git grep 'foo' | grep baa )

I do this often after shelling out to bash $ git grep 'banner-image' | grep mb3 Can I do it without leaving emacs?
1
vote
1answer
52 views

Paths not hyperlinking correctly

Recently when running compile, the error messages don't get hyperlinked properly. I get this type of error message: ../build/obj/DerivedClass.cpp:45:18: error: expected type-specifier The buffer ...
9
votes
3answers
293 views

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 ...
1
vote
3answers
171 views

How do I create a command that searches a specific directory?

I would like to create a command (C-s C-k or something?) that searches a specific directory every time I call it. It would search files within that directory for a string (may contain spaces) and then ...
3
votes
2answers
181 views

How can I create a new buffer for the second run of grep, to avoid overwriting the results of the first run of grep?

When I run grep by M-x grep, I get results in a buffer. When i run grep again M-x grep, the new results overwrite the previous ones in the same buffer. How can I create a new buffer for the second ...
6
votes
3answers
999 views

How to grep marked files in the dired mode of emacs?

I hope it's a simple problem.. I'd like to search for the regexp 'thisWord' only in the marked files of a dired buffer. Usually I used in the dired buffer: M-x grep and then in the mini-buffer grep ...
2
votes
3answers
118 views

Is there a command in emacs similar to `find` in findutils?

In emacs, the command M-x grep runs grep program. Is there a command in emacs for running find in findutils, or do similar thing? Thanks.
4
votes
2answers
286 views

Show the matching line in the center of the screen instead of the bottom when opening a grep result

When I grep something inside emacs and click to open one of the matching files. The matching line is always displayed at the bottom of the screen, and I have to scroll it up for a better view. Is it ...
1
vote
0answers
74 views

Can emacs emulate zgrep -a in zrgrep?

Currently I can grep (in command line) the gzip files I receive using the command zgrep -a something logs.tar.gz it outputs every line inside the logs.tar.gz but without the file where it was found, ...
3
votes
1answer
684 views

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.
2
votes
1answer
148 views

grep/ag/etc results buffer: how to strip leading whitespace?

I'm using ag.el as a front-end for the ag search utility. The results are displayed in a compilation buffer in the form <file>:<line>:<column>:<matching-text>. The matching-...
5
votes
1answer
61 views

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 ...
3
votes
3answers
609 views

Multiple grep results buffers

Let's say I want to grep word1 and word2. If I use the grep command for word1 I get the results in the *grep* buffer. If I then use the grep command for word2 I loose the old results and get the ...
0
votes
1answer
185 views

How to enable “Entering Directory” matching in grep output?

I have a grep-like script that I run via M-x grep, that changes its working directory, but outputs make-like "Entering directory `/a/b/c/d'" messages (to keep emacs informed). This has worked fine ...
15
votes
5answers
7k views

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 ...
5
votes
2answers
267 views

How to grep all the Info manuals with a regexp search

People often recommend on emacs.stackexchange.com and stackoverflow.com (in the Emacs tag) that we should learn to "ask Emacs". The built-in Info-mode is not capable of performing a recursive regexp ...
3
votes
1answer
238 views

How to align grep output?

I use grep-mode for a set of files and wgrep (writable grep buffer) for editing them. The buffer usually looks like: I want to find a way to change the view like this: wgrep and compile-goto-error ...
2
votes
0answers
273 views

How can I replace grep with sift or ag in helm-grep? (Not helm-do-ag)

I've currently got a custom function that I use to grep through files in helm. ;; Search for the thing that the cursor is on or that's already hilighted. If there's nothing, ;; switch back to ...
4
votes
1answer
133 views

How can I recenter grep or compile window on next error

On next-error in the grep or compilation window, I can use something like (setq next-error-recenter 35) to ensure that window displaying the match scrolls to show the whole match, as described in ...
3
votes
2answers
1k views

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 ...