0

Emacs 27.1

Linux Mint 21

I have text modifyNetwork in 50 files in differents folders. I need to replace them by text performCommand.

What is the easiest way to replace text in all files in all subfolders?

3
  • 2
    Whatever method you use (in Emacs or not), you are going to have to specify the list of files on which to operate. That's not something that anybody here can give you any advice on, unless you say something more about what connects the 50 files together. If nothing, then you are going to have to make a list of those files manually. Once you've done that, the substitution is no problem (a sed as a comment in the answer indicates). But that's hardly an Emacs problem and therefore unsuitable for Emacs SE.
    – NickD
    Commented Jun 18, 2023 at 1:35
  • May be this helps: github.com/mhayashi1120/Emacs-wgrep and sachachua.com/blog/2021/08/… Commented Jun 18, 2023 at 5:49
  • @OliverKnodel Yes, the rgrep + package wgrep are help me Commented Jun 18, 2023 at 8:34

2 Answers 2

3

18.20 Filesets:

If you regularly edit a certain group of files, you can define them as a fileset. This lets you perform certain operations, such as visiting, query-replace, and shell commands on all the files at once.

That's what you need.

0

If all your files belong to a single project, then project-query-replace-regexp is a solution. If they do not, you can use sed.

3
  • Reihs No this files not belongs to project. Commented Jun 17, 2023 at 20:01
  • 1
    Then I do not know any appropriate Emacs feature. But a shell script using sed -i s/modifyNetwork/performCommand/ may do the job. @a_subscriber Commented Jun 17, 2023 at 20:19
  • multi-occur is a possibility. You will need a way to specify all the files that you want to operate on.
    – NickD
    Commented Jun 17, 2023 at 22:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.