Using Here Document to Install Packages in Ubuntu without Confirmation

While restoring my apps, I was thinking, how can I install a package from a list that I saved, without having to export them. Well, I thought of this loop, which can be used to either install one package or a multiple package. What started as one line, ended up in full fledge script!

getting packages from packages.txt file

while read line; do 
sudo apt-get install $line << INSTALL 
done < packages.txt

installing one package without waiting to press “y” for confirmation

sudo apt-get install -y --force-yes package


sudo apt-get install package << INSTALL
Share This!

Leave a Reply

Your email address will not be published.