Using a file to install packages with apt-get

As specified in the comments of your question, you can build a simple text file, called packages.txt, listing the packages to install:

iceweasel
terminator
vim

and then run the following command:

cat packages.txt | xargs sudo apt-get install

xargs is used to pass the package names from the packages.txt file to the command line. From the man page:

xargs reads items from the standard input, delimited by blanks (which can be protected with double or single quotes or a backslash) or newlines, and executes the command (default is /bin/echo) one or more times with any initial- arguments followed by items read from standard input.


Improving a bit on the answer of @ortomala-lokni, you can give the file directly as an argument to xargs:

xargs -a packages.txt sudo apt-get install

Optionally you can give xargs the -r option to prevent the apt-get call from being run at all if your packages.txt does not contain any non-whitespace characters.