modify official-package-repositories.list in script

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Locked
SMS

modify official-package-repositories.list in script

Post by SMS »

I am trying to modify the default ubuntu repositories in official-package-repositories.list in a script. I want to put a different mirror in, because archive.ubuntu.com is slow as _.

I've tried sed and awk, but i can't get the syntax right, or some process is not allowing it to be changed, or something.

The only way i've been able to do it is through echo | sudo tee -a, but that just appends the entries, and apt fails to read them, because there is some weird character right above my new entries.

What's the really right way to do this?

Thanks for your help.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
karlchen
Level 23
Level 23
Posts: 18212
Joined: Sat Dec 31, 2011 7:21 am
Location: Germany

Re: modify official-package-repositories.list in script

Post by karlchen »

Anything wrong with manually editing the file?

Code: Select all

sudo gedit /etc/apt/sources.list.d/official-repository-packages.list
Image
The people of Alderaan have been bravely fighting back the clone warriors sent out by the unscrupulous Sith Lord Palpatine for 771 days now.
Lifeline
Monsta
Level 10
Level 10
Posts: 3071
Joined: Fri Aug 19, 2011 3:46 am

Re: modify official-package-repositories.list in script

Post by Monsta »

SMS wrote:What's the really right way to do this?
The really right way to do this is to run Software Sources (mintSources) and choose a mirror.
mintSources always overwrites this file anyway.
User avatar
xenopeek
Level 25
Level 25
Posts: 29597
Joined: Wed Jul 06, 2011 3:58 am

Re: modify official-package-repositories.list in script

Post by xenopeek »

Either write a script and run that with sudo ("sudo ./myscript"), or run sed or awk with sudo. For sed that would be something like "sudo sed -i 's/search/replace/' file"; the -i makes sed edit the file in place.
Image
Locked

Return to “Scripts & Bash”