Timeline for Replace string within multiple files using per line strings from one file
Current License: CC BY-SA 4.0
9 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Aug 4, 2020 at 5:26 | history | edited | Stéphane Chazelas | CC BY-SA 4.0 |
added 242 characters in body
|
| Aug 3, 2020 at 23:10 | vote | accept | 0m3rta3 | ||
| Aug 3, 2020 at 23:09 | comment | added | 0m3rta3 | I’m gonna be honest with you. The whole read dummy line...!Through me for my own kind of loop. I’m still kinda new to scripting and stuff beyond just above the basics. So I had to go and read up what the heck that was about. Anyway. Not only did it work but I think I’ve learnt more from yours and the other answer too with regards to text processing, bash, loops and sed than I have in the last 3 days looking up solutions on how to do this. Thank you! | |
| Aug 3, 2020 at 22:35 | comment | added | Hauke Laging |
@0m3rta3 The grep is just supposed to show to readers what my files look like so that my code can easily be tested. The sed should change just the one respective line in a multi-line file. Have you tried that at all? Of course, the sed call needs a separator char which does not appear in your URLs or you will get into quoting hell.
|
|
| Aug 3, 2020 at 22:28 | comment | added | 0m3rta3 | URL’s might not be the best example because I don’t have to worry about escaping special characters in the majority of my cases. It’s just a simple replace(this)-with(that) | |
| Aug 3, 2020 at 22:16 | comment | added | 0m3rta3 | But the grep preparation wouldn’t give that kind of output. Unless I’m missing something? Which is possible. I’m using this in a couple of ways. One example is where the directory of files are puppeteer scripts. The 2nd column of the single file are various URLs (all different). I then place an uncommon string (#P#) everywhere I want a URL inserted and then loop the list to insert each url into each script. So each script has different calls and different URLs. This is just an example one of the things I’m trying to do. | |
| Aug 3, 2020 at 22:10 | comment | added | Hauke Laging | @0m3rta3 That's what I assumed. Should not be a problem for my solution. | |
| Aug 3, 2020 at 22:04 | comment | added | 0m3rta3 |
Sorry I don’t think i was clear that only the single file has one ‘result’ per line. The txt files within the directory have numerous lines but the string #P#only occurs one time in each file. Your example has however solved a separate issue I had with a similar issue on separate files. So thank you
|
|
| Aug 3, 2020 at 21:53 | history | answered | Hauke Laging | CC BY-SA 4.0 |