Replace in multiple files - graphical tool for Linux
Asked Answered
S

7

26

It needs to be graphical. No sed, awk, grep, perl, whatever. I know how to use those and I do use them now, but I need to cherry-pick each replace in 300+ files.

I want a tool where I can:

  • type a search string
  • type a replace string
  • select a directory and file extension

and it would recursively go into each file in that directory and its sub-directories, open it and scroll to the place where search string is and offer two options:

  • replace (and find next)
  • find next

Nothing more. Reg.exp. support is a plus, but not required.

SOLVED: Regexxer is exactly what I needed. In case someone needs it on Slackware, here's what you need to download and how to compile it (choosing correct version of each dependency can be a PITA)

Spiraea answered 9/10, 2008 at 20:58 Comment(1)
Latest 0.10 source version from year 2011 with 8 downloads/week: regexxer.sourceforge.net sourceforge.net/projects/regexxer . Also available in Ubuntu based Linux distributions as installable package.Insistent
R
30

I think regexxer is exactly what you're looking for:

Regexxer

regexxer is a nifty GUI search/replace tool featuring Perl-style regular expressions. If you need project-wide substitution and you’re tired of hacking sed command lines together, then you should definitely give it a try.

See also the screenshot, looks a lot like what you're describing:

screenshot

Reverberation answered 9/10, 2008 at 21:22 Comment(4)
I would vote this down but do not have enough points to do that. regexxer does not have a multi-line search field which and therefor can only search and replace a single line. The jedit tool handles search and replace of multi-line text and is therefor a much better solution.Jellicoe
Agree with Farrukh, see his answer and upvote please: https://mcmap.net/q/516133/-replace-in-multiple-files-graphical-tool-for-linuxCortege
JEdit is much more user friendly.Erichericha
Warning because Regexxer is quite outdated. Cannot install it. I guess it is not for new distribution in 2022Demello
L
8

Emacs + dired + query-replace-regexp

For complete recipe follow this link (it's rather long, covering all possible alternatives),

Lorant answered 9/10, 2008 at 21:1 Comment(2)
I've used this in Emacs, and it's awesome. It does exactly what the OP wants.Weltschmerz
Although I like Regexxer better, I'll vote you up because it is a valid solution. Thanks.Killarney
Z
7

jEdit does exactly what you need. It is written in Java and works well in Linux, Windows and OS X (probably other operating systems also).

Zendah answered 9/10, 2008 at 21:54 Comment(5)
Interesting. I used jEdit 3-4 years ago, but don't remember that feature. Is is available via some add-on? Or maybe it was added in the meantime...Killarney
I don't know how long it's been there, but the text search dialog box allows searching for regex matches, and you can search all open files or a whole directory if you like.Zendah
SStrangely, the linux version of jedit doesn't have the multiline text area in the search and replace window (version 4.2final)Veilleux
The jedit solution is the only one I have found that handles multi-line search and replace across multiiple files. The regexxer tool does not handle multi-lines in my experience. jedit on ubuntu linux indeed does have a multi-line text area using Search / Search In Directory menu action. This response should have the highest points but does not for some reason while the response with highest points (regexxer) does not support multi-line search.Jellicoe
jedit is user friendly. The other tools don't seem to be at all of a step up from bash so what's the pointErichericha
I
5

Lately Kate (if you use KDE) can do it, but in a very tricky way. Go to "Edit>Search in Files", and choose the folder within which your files exist.

The trick is that only after the search results appear, you will find a text box and a button called "Replace checked". This button will do what you want.

Incompressible answered 17/11, 2013 at 8:36 Comment(1)
This is only available if you activate Kate's Search & Replace plugin.Chrysolite
N
3

I use gVim for this task all the time. I open up all the files at once, then use the commands to perform a subsitution on each file, asking for confirmation. Generally I use < 20 files, so I open them as tabs and use this:

:tabdo %s/foo/bar/gc

gVim works fine on Windows :) My coworkers often use Textpad to do this same thing, but I'd say gVim is much more efficient at it.

Nipple answered 9/10, 2008 at 22:15 Comment(2)
bufdo works on buffers instead of tabs, which is pretty useful. Any way to get it to automatically save the files as it goes through buffers?Impotence
I'm not sure about saving as it goes, but you can save all of them at once when it's done with ":wa". You could also do ":tabdo :w", I think, but I see no point to it. And of course you could use buffers :).Nipple
A
2

If you are a KDE user there's also kfilereplace.

Anglonorman answered 28/8, 2010 at 7:44 Comment(0)
C
1

jdReplace

Can handle very large amount of files. Easy to use, fast, and its repository is with the strong privacy and strong security Codeberg.

Carolanncarole answered 3/12, 2023 at 20:49 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.