[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to grep for a string spanning multiple lines?
From: |
Jean Louis |
Subject: |
Re: How to grep for a string spanning multiple lines? |
Date: |
Sat, 26 Nov 2022 11:27:28 +0300 |
User-agent: |
Mutt/2.2.7+37 (a90f69b) (2022-09-02) |
* Marcin Borkowski <mbork@mbork.pl> [2022-11-26 09:45]:
> Hi all,
>
> assume I have a file (probably an Org mode one) with some stuff
> I archived from the 'net. (I'm going to start to sue
> youtube-sub-extractor.el.) Here is my problem: assume I remember that
> someone in some video said something, and I want to find that part.
> However, it turns out that it is split between two (or more) lines.
>
> Traditional `grep' is not helpful in this situation. Neither is
> isearch, nor swiper. One idea would be to convert the subtitles to one
> long line (which is an option), but are there any other ways to search
> for a string spanning more than one line (and not knowing which words
> are separated by a space and which ones by a newline)?
>
> Both Emacs-y and shell-y tools would be appreciated.
I was just searching for pattern here:
(define-skeleton with-tabulated-id
"Helper skeleton for `tabulated-list-get-id'"
nil
"(defun " (skeleton-read "Function name: ") " (" (skeleton-read "Arguments: "
"&optional id") ")
\"\"
(interactive)
(when-tabulated-id \"" (skeleton-read "Table: ") "\"
))")
by using this method and `grep':
$ grep -Pazo 'with-tabulated-id.*\n.*Helper' rcd-cf.el
with-tabulated-id
"Helper~/Programming/emacs-lisp
As advised here:
https://stackoverflow.com/questions/152708/how-can-i-search-for-a-multiline-pattern-in-a-file
So grep can find patterns across multiple lines.
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
- How to grep for a string spanning multiple lines?, Marcin Borkowski, 2022/11/26
- Re: How to grep for a string spanning multiple lines?,
Jean Louis <=
- Re: How to grep for a string spanning multiple lines?, tomas, 2022/11/26
- Re: How to grep for a string spanning multiple lines?, Jean Louis, 2022/11/26
- Re: How to grep for a string spanning multiple lines?, Eli Zaretskii, 2022/11/26
- Re: How to grep for a string spanning multiple lines?, Jean Louis, 2022/11/26
- Re: How to grep for a string spanning multiple lines?, Michael Heerdegen, 2022/11/27
- Re: How to grep for a string spanning multiple lines?, Jean Louis, 2022/11/27
- Re: How to grep for a string spanning multiple lines?, Michael Heerdegen, 2022/11/27
- Re: How to grep for a string spanning multiple lines?, Jean Louis, 2022/11/27
Re: How to grep for a string spanning multiple lines?, Arthur Miller, 2022/11/26
Re: How to grep for a string spanning multiple lines?, Emanuel Berg, 2022/11/26