Find and replace

Questions about applications and software
Forum rules
Before you post please read how to get help
User avatar
Flemur
Level 18
Level 18
Posts: 8477
Joined: Mon Aug 20, 2012 9:41 pm
Location: Potemkin Village

Re: Find and replace

Post by Flemur »

Klaas Vaak wrote:
Fri Sep 20, 2019 3:58 am
I 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
Last edited by Flemur on Thu Sep 26, 2019 12:30 pm, edited 1 time in total.
Please edit your original post title to include [SOLVED] if/when it is solved!
Your data and OS are backed up....right?
Klaas Vaak
Level 4
Level 4
Posts: 214
Joined: Fri Feb 16, 2018 6:18 am
Location: GMT+2

Re: Find and replace

Post 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 ;-)
User avatar
Flemur
Level 18
Level 18
Posts: 8477
Joined: Mon Aug 20, 2012 9:41 pm
Location: Potemkin Village

Re: Find and replace

Post 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.
Please edit your original post title to include [SOLVED] if/when it is solved!
Your data and OS are backed up....right?
Klaas Vaak
Level 4
Level 4
Posts: 214
Joined: Fri Feb 16, 2018 6:18 am
Location: GMT+2

Re: Find and replace

Post 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.
Post Reply

Return to “Software & Applications”