e.g.: http://cybernetnews.com/find-replace-multiple-files/
how can i do something like that in ubuntu 11.10
|
e.g.: http://cybernetnews.com/find-replace-multiple-files/ how can i do something like that in ubuntu 11.10 |
|||
|
|
|
Here I use sed to replace every occurrence of the word "cybernetnews" with "cybernet" in every file with the extension, c, in the directory, /home/user/directory/.
A more generic variation where you search recursively from the directory of execution and operate on only regular, readable, writeable files:
|
|||||||||||||
|
|
The stream editor,sed, is a powerful utility for this kind of work and is my first choice, however, if you want to do this from an ordinary text editor using an Ubuntu based native application, I would suggest you take a look at Jedit, It is available in the repositories and can be installed by typing in your console:
Start jedit, click the search menu item, in the menu list, click the Search in Directory item, you will be presented with the dialog below:
This is similar to that of Notepad++ and does the same thing, I believe this is what you want. |
||||
|
|
|
Check with Geany, it is perfect NPP replacement for Linux. You can do exactly that plus you can use regex. |
||||
|
|
replaces any occurence of oldtext by newtext in all files in the current folder. However you will have to escape all perl special characters within oldtext and newtext using the backslash. |
|||
|
|
|
It will not have the graphical interface but I would urge you to examine sed (man sed). It is the stream editor that has been in existence from the start of UNIX. |
|||
|
|
|
I wrote a little script for just this thing. If you only need the basics and are not familiar with sed etc, take a look here: http://www.csrdu.org/nauman/2010/12/30/bash-script-to-find-and-replace-in-a-set-of-files/ The script is the following:
|
|||
|
|
|
You can use this script, copy code and make a file I have modified it a little; please tell me your opinion.
|
||||
|
|