Quantcast
Viewing latest article 2
Browse Latest Browse All 7

Answer by whitis for How to automatically update /etc/apt/sources.list with source URIs on Ubuntu 16.04?

simpler solution that does what the others have posted more succinctly:

sudo perl -p -i -n -e "s/# *deb-src/deb-src/"  /etc/apt/sources.list

Key distinctions: Perl has the -i inplace option which modifies files in place; I did not add a suffix for backup files because I didn't want the backup files to accidentally be treated as data files. And " *" deals with optional whitespace. "perl -p -n -e" is mostly the same as "sed -e", though watch out for greedy regex matching.

It has the same limitations the others do: it enables sources even if the original wasn't enabled (i.e. partners), and it doesn't work on /etc/apt/sources.list.d. The following will also process /etc/apt/sources.list.d* but makes a backup first.

(cd /etc/apt/; sudo tar cvf sources.list.tar sources.list sources.list.d);  for i in /etc/apt/sources.list /etc/apt/sources.list.d/*; do sudo perl -p -i -n -e "s/# *deb-src/deb-src/" $i; done

Viewing latest article 2
Browse Latest Browse All 7

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>