Page 2 of 2

Re: Find and replace

Posted: Thu Sep 26, 2019 11:36 am
by Flemur
Klaas Vaak wrote: Fri Sep 20, 2019 3:58 amI sometimes need to find in multiple files a word, or sentence, and replace it/them with another.
With Unix and a real "vi", I used to do that, like this:

Code: Select all

vi list-of-files < list-of-vi-commands
Where list-of-vi-commands is like:

Code: Select all

:1,$s/oldword/newword/g
...etc...
:wq
but now, since, IIRC, the "real vi" is not open source and in linux it's been replaced by "vim", it might act funny depending on your OS. If the 'vi' doesn't work, try 'ex'.

Edit: it works with Mint 18.3, although it doesn't sound very happy about it:
[........DELETED...] it only edits the first file. Same result with 'ex'. IT DOESN"T WORK

Re: Find and replace

Posted: Thu Sep 26, 2019 11:44 am
by Klaas Vaak
Thanks for the tip Flemur. I am bookmarking this page since it has many very F & R good tips; for now I'll stick with FAR.

Talking about tips, I notice in your signature you like Manjaro. I recently discovered Artix, which I installed on a small, 2 GB RAM, 32 GB eMMC hybrid, and it runs like a dream - very stable and light, also based on Arch but with a good GUI. And it is on a rolling release as well, and does not use systemd, which some people hate with all their soul. 1 thing I really like it Pamac software manager; it does not come with the .iso image, but installed it separately and uninstalled Octopi.
Anyway, Artix is worth checking out ;-)

Re: Find and replace

Posted: Thu Sep 26, 2019 11:50 am
by Flemur
Klaas Vaak wrote: Thu Sep 26, 2019 11:44 am Thanks for the tip Flemur.
Well, it didn't work! (It also didn't work in Manjaro, which I think has a different 'vim', and no 'ex')
It just edits the first file, tho you could pass it one file at a time with a loop @catweasel, although that kind of defeats the purpose, which was to not have to write a script.
One cool thing about the real Unix vi: it would show the file on the monitor as it edited it, like watching somebody who could type 1000 WPM.

Code: Select all

Anyway, Artix is worth checking out ;-)
I will! I don't hate systemd, but I definitely DO NOT like any of the other software from freedesktop, and maybe artix has less of it.

Re: Find and replace

Posted: Thu Sep 26, 2019 11:57 am
by Klaas Vaak
Flemur wrote: Thu Sep 26, 2019 11:50 am Well, it didn't work! (It also didn't work in Manjaro, which I think has a different 'vim', and no 'ex')
Sorry, I missed the "edit" bit at the bottom of your original reply.