modify official-package-repositories.list in script

Forum rules
Before you post please read how to get help
SMS
Level 1
Level 1
Posts: 10
Joined: Wed Jul 03, 2013 11:28 am

modify official-package-repositories.list in script

Postby SMS » Sun May 04, 2014 9:37 am

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.

User avatar
karlchen
Level 16
Level 16
Posts: 6615
Joined: Sat Dec 31, 2011 7:21 am

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

Postby karlchen » Sun May 04, 2014 9:46 am

Anything wrong with manually editing the file?

Code: Select all

sudo gedit /etc/apt/sources.list.d/official-repository-packages.list
Image

Monsta
Level 9
Level 9
Posts: 2935
Joined: Fri Aug 19, 2011 3:46 am

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

Postby Monsta » Sun May 04, 2014 10:19 am

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 23
Level 23
Posts: 19375
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

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

Postby xenopeek » Sun May 04, 2014 1:23 pm

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


Return to “Scripts & Bash”

Who is online

Users browsing this forum: No registered users and 2 guests