Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to add PPAs on Ubuntu 14.04.3 from a file that contains a list of repositories, as follows:

sudo add-apt-repository ppa: $ (cat ppas.list)

or

sudo add-apt-repository $ (cat ppas.list)

or yet

cat ppas.list | xargs sudo add-apt-repository

But these don't work and the following error appears: "Error: need a single repository as argument".

Can someone assist?

share|improve this question

closed as off-topic by kos, Serg, David Foerster, heemayl, Braiam Jan 26 at 4:27

  • This question does not appear to be about Ubuntu within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

3  
I'm voting to close this question as off-topic because it has been cross-posted on Stack Overflow: stackoverflow.com/q/35003324/4316166 – kos Jan 25 at 22:41

Use -L1 to tell xargs to use only one input line per command:

cat ppas.list | xargs -L1 sudo add-apt-repository
share|improve this answer
    
Nice, I didn't know about that option. However you could also suggest to use the -a option of xargs instead of the useless cat (xargs -a ppas.list -L1 sudo add-apt-repository). – kos Jan 25 at 22:11
    
This will choke badly on whitespace(s) in the name.. – heemayl Jan 26 at 1:25
    
@heemayl: Whitspaces aren't allowed in PPA names – Florian Diesch Jan 26 at 1:34

You could use a loop (and you'll probably want to add the -y option to the add-apt-repository command to avoid being prompted for a confirmation for each repository):

while read x; do
    sudo add-apt-repository -y "$x"
done <file
share|improve this answer
up vote 2 down vote accepted

It works with the following command:

for i in $(cat ppas.list); do sudo add-apt-repository "$i"; done
share|improve this answer
    
I found the solution: stackoverflow.com/questions/35003324/… – aleroxac Jan 25 at 22:27

Not the answer you're looking for? Browse other questions tagged or ask your own question.