Installing APT packages from a requirements file
Sometimes you need to install Debian or Ubuntu APT packages based on a list of packages listed in a file. There is no built-in support for this in APT (unlike python's pip where it is possible to specify a requirements file using pip3 install --requirement my-requirements-file.txt).
Here's how to install Debian or Ubuntu packages from a list using command line utilities (side note: this works in Raspbian too). This method has the benefit of allowing comments in the requirements file:
sed 's/#.*//' my-requirements-file.txt | xargs sudo apt-get install
The requirements file can be formatted like this:
# Tools. git httpie # HTTP client. geany # Text editor. # Interpreters. python3 racket # It's okay for comments to be preceeded by whitespace.
Notice that comments start with the # character and can be either be inline or on their own line.
How it works
sed 's/#.*//' <file> reads the file and outputs the contents of the file with all occurrences of things starting with the character # substituted with nothing, effectively removing the comments.
The text that has been processed with sed is the piped (i.e. fed) into xargs, which constructs the arguments for sudo apt-get install using the text that was fed into xargs.
Hope this helps.