Results 1 to 6 of 6

Thread: Referencing a text file with apt-get install

  1. #1
    Join Date
    Jul 2009
    Location
    AL, USA
    Beans
    330
    Distro
    Kubuntu 16.04 Xenial Xerus

    Question Referencing a text file with apt-get install

    I have seen this somewhere, but I can't seem to find it anywhere.
    If I keep a list of apps to be installed in a text file, what is the format of the list (app1, app2 or app1 app2) and how do I reference to it when I use apt-get install....?
    It would be a useful command to know, as well as helping me to understand more about using input/output at the CLI. Thanks!
    Thinkpad T430, Intel i5-3320M (Ivy), 8GB RAM, Intel HD 4000, 500GB HDD: Xubuntu 20.04 LTS 64bit

  2. #2
    Join Date
    Jun 2008
    Location
    New York
    Beans
    139
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Referencing a text file with apt-get install

    if you just put them into a file separated by spaces this works:

    'cat package-list | xargs sudo apt-get install '
    on freenode as Zeike or brandonj, depending on my mood.

  3. #3
    Join Date
    Jul 2009
    Location
    AL, USA
    Beans
    330
    Distro
    Kubuntu 16.04 Xenial Xerus

    Re: Referencing a text file with apt-get install

    Sorry, could you be a little more specific, or not so specific? What part of that is the "filename"? What is xargs?
    Thinkpad T430, Intel i5-3320M (Ivy), 8GB RAM, Intel HD 4000, 500GB HDD: Xubuntu 20.04 LTS 64bit

  4. #4
    Join Date
    Jun 2008
    Location
    New York
    Beans
    139
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Referencing a text file with apt-get install

    Quote Originally Posted by zer010 View Post
    Sorry, could you be a little more specific, or not so specific? What part of that is the "filename"? What is xargs?
    'package-list' is the name of the file with the packages, separated by spaces:

    like this:
    Code:
    irssi nmap ubuntu-desktop blah
    xargs allows you to "build and execute command lines from standard input". see 'man xargs'

    Essentially what is happening here is:
    'cat package-list': you're printing the contents of the file package-list to the standard output
    ' | ': this is a pipe, it sends the standard output from the previous command to the standard input of the next.
    'xargs sudo apt-get install ': xargs takes the standard input, and adds it on to the following command (sudo apt-get install) as arguments.

    So if your file looks like my example above, this command would be like typing 'sudo apt-get install irssi nmap ubuntu-desktop blah'
    Last edited by Zeike; August 8th, 2010 at 02:44 AM.
    on freenode as Zeike or brandonj, depending on my mood.

  5. #5
    Join Date
    Jul 2009
    Location
    AL, USA
    Beans
    330
    Distro
    Kubuntu 16.04 Xenial Xerus

    Re: Referencing a text file with apt-get install

    Cool! Thanks very much! I never heard of xargs. To the manual, I go!
    Thinkpad T430, Intel i5-3320M (Ivy), 8GB RAM, Intel HD 4000, 500GB HDD: Xubuntu 20.04 LTS 64bit

  6. #6
    Join Date
    Feb 2010
    Beans
    12

    Re: Referencing a text file with apt-get install

    Excellent, just wanted to say thanks, I tried the same and "xargs" was the missing segment, worked liked a charm.

    I also added "-y" to assume yes to all questions asked:

    cat list-of-packages.txt | xargs sudo apt-get install -y

    Hope that helps someone to avoid confirming what they are sure they want to install

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •