Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I see this discussion: How does one find and replace text in all open files with geany?

I want to find and replace all files in a directory. The method suggested in the answer, is very good to find. Now I need to open all found files and use Geany. If the files are hundreds it's not possible to by clicking on the link in Geany.

How to do automatically?

share|improve this question

While not an answer specific to Geany, could you do this instead using sed at the command line?

This will recursively replace "foo" with "bar" in a directory.

find . -type f | xargs -i sed -i -e "s/foo/bar/g" "{}"

share|improve this answer
And I have to replace "bau/foo/" with "bea/bar/roo"? How can I write well it? Thanks – SPS Jun 3 '13 at 19:32
In the part "s/foo/bar/g" it means "Substitute (s) 'foo' with 'bar', on every line (g)" so! If you have a file that has the word "cat" and you want to replace it with dog, the whole line would look like: find . -type f | xargs -i sed -i -e "s/cat/dog/g" "{}" – dougBTV Jun 3 '13 at 20:44
@SPS There are two ways. You can put a backslash before the slash to indicate that it's to be interpreted literally, as in sed -e 's/bau\/foo\//bea\/bar\/roo/g'. Or you can use a different character as the separator instead of slash, e.g. sed -e 's~bau/foo/~bea/bar/roo~g'. – Gilles Jun 3 '13 at 22:25
Thanks @Gilles didn't quite see that he was looking to replace a literal /, good eye! – dougBTV Jun 4 '13 at 12:41
thanks to Gilles – SPS Jun 10 '13 at 19:36

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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