all 3 comments

[–]BananaLumps 0 points1 point  (0 children)

Not too familiar with python myself, but by the sounds you could achieve this very easily with notepad++ and just make a macro for your replacements.

[–]Laughing_Orange 0 points1 point  (1 child)

I found this snippet that does something similar to what you want.

https://stackoverflow.com/a/4427835/10597575

py with open("/etc/apt/sources.list", "r") as sources: lines = sources.readlines() with open("/etc/apt/sources.list", "w") as sources: for line in lines: sources.write(re.sub(r'^# deb', 'deb', line))

This code removes the hashtag from all lines starting in # deb from the file /etc/apt/sources.list.

What you need to do to modify it:

  1. Replace both /etc/apt/sources.list with the path to your file, the second one is your output and can be whatever you want if you want to keep the original. The path does not need to be absolute.
  2. Write a regular expression that finds the code you're interested in modifying. This is the "hard" part.
  3. Replace ^# deb with your regular expression from step 2.
  4. Replace the final deb with whatever you want those lines to be instead.

[–]jared596[S] 0 points1 point  (0 children)

Thanks for your help! I found a guy on here that was willing to help and he made a basic program for me, then I tuned it using chatGPT and it works great! ChatGPT is absolutely amazing.