apt install












1














This looks good:



for i in package1 package2 package3; do
sudo apt-get install -y $i
done


but with the packages listed in a file:



package1
package2
..


each on its own line. Looking for simplest script to read, performance not really an issue. Of course, the odd package will require some human intervention during install to agree or for configuration.



As an aside, what's the "real" way of dealing with large lists of packages to be installed? I'm just looking for monkey-see-monkey-do.










share|improve this question
























  • I don't really understand your question, you could read from the file and run the apt command on each read line!
    – George Udosen
    52 mins ago










  • LOL, yes, exactly. How? (I'll google that, also, of course.)
    – Thufir
    50 mins ago
















1














This looks good:



for i in package1 package2 package3; do
sudo apt-get install -y $i
done


but with the packages listed in a file:



package1
package2
..


each on its own line. Looking for simplest script to read, performance not really an issue. Of course, the odd package will require some human intervention during install to agree or for configuration.



As an aside, what's the "real" way of dealing with large lists of packages to be installed? I'm just looking for monkey-see-monkey-do.










share|improve this question
























  • I don't really understand your question, you could read from the file and run the apt command on each read line!
    – George Udosen
    52 mins ago










  • LOL, yes, exactly. How? (I'll google that, also, of course.)
    – Thufir
    50 mins ago














1












1








1







This looks good:



for i in package1 package2 package3; do
sudo apt-get install -y $i
done


but with the packages listed in a file:



package1
package2
..


each on its own line. Looking for simplest script to read, performance not really an issue. Of course, the odd package will require some human intervention during install to agree or for configuration.



As an aside, what's the "real" way of dealing with large lists of packages to be installed? I'm just looking for monkey-see-monkey-do.










share|improve this question















This looks good:



for i in package1 package2 package3; do
sudo apt-get install -y $i
done


but with the packages listed in a file:



package1
package2
..


each on its own line. Looking for simplest script to read, performance not really an issue. Of course, the odd package will require some human intervention during install to agree or for configuration.



As an aside, what's the "real" way of dealing with large lists of packages to be installed? I'm just looking for monkey-see-monkey-do.







apt bash package-management software-installation automation






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 39 mins ago

























asked 1 hour ago









Thufir

1,51284394




1,51284394












  • I don't really understand your question, you could read from the file and run the apt command on each read line!
    – George Udosen
    52 mins ago










  • LOL, yes, exactly. How? (I'll google that, also, of course.)
    – Thufir
    50 mins ago


















  • I don't really understand your question, you could read from the file and run the apt command on each read line!
    – George Udosen
    52 mins ago










  • LOL, yes, exactly. How? (I'll google that, also, of course.)
    – Thufir
    50 mins ago
















I don't really understand your question, you could read from the file and run the apt command on each read line!
– George Udosen
52 mins ago




I don't really understand your question, you could read from the file and run the apt command on each read line!
– George Udosen
52 mins ago












LOL, yes, exactly. How? (I'll google that, also, of course.)
– Thufir
50 mins ago




LOL, yes, exactly. How? (I'll google that, also, of course.)
– Thufir
50 mins ago










2 Answers
2






active

oldest

votes


















2














There is the xargs program which transforms a file to command-line arguments. Simply prepend xargs to the command (with all arguments) for which you’d like to supply additional arguments from the file (let’s call it list.txt) and let xargs to read your file using standard input redirection.



< list.txt xargs sudo apt-get install -y


You can test it by putting echo before (or instead of) sudo or removing the -y option.






share|improve this answer























  • but can you make it simpler for this monkey?
    – Thufir
    22 mins ago








  • 1




    I am sorry, I don’t think there is any way to make this command simpler. Every character in this command has its own purpose. The only thing I can simplify is to write apt instead of apt-get.
    – Melebius
    19 mins ago












  • I know -- I was kidding. But, thanks.
    – Thufir
    18 mins ago



















2














Something like this?



# check that the filename was supplied (keeping it simple for the example)
set -o nounset

packagefile=$1

# initialize the package variable
packages=''

# read the lines of the package file
while IFS= read -r line; do
packs+=" $line"
done < $packagefile

# apt install all of the packages
apt install -y $packs





share|improve this answer





















  • yes, perfect thanks. As an aside, is it possible or advisable to pipe apt search output through a script or utility? Assuming you know ahead of time that the result set is limited. You already answered the question I asked, it's just an aside.
    – Thufir
    47 mins ago








  • 1




    You can pipe the output but IMO that's really asking for it since you could get many matches that you didn't intend. I'd recommend outputing to a file first (like: apt search some-pack_name > packages) and then editing that file before doing the install.
    – Eric Mintz
    28 mins ago










  • It's the editing which is annoying.
    – Thufir
    23 mins ago











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1106268%2fapt-install-list-of-packages-from-file%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














There is the xargs program which transforms a file to command-line arguments. Simply prepend xargs to the command (with all arguments) for which you’d like to supply additional arguments from the file (let’s call it list.txt) and let xargs to read your file using standard input redirection.



< list.txt xargs sudo apt-get install -y


You can test it by putting echo before (or instead of) sudo or removing the -y option.






share|improve this answer























  • but can you make it simpler for this monkey?
    – Thufir
    22 mins ago








  • 1




    I am sorry, I don’t think there is any way to make this command simpler. Every character in this command has its own purpose. The only thing I can simplify is to write apt instead of apt-get.
    – Melebius
    19 mins ago












  • I know -- I was kidding. But, thanks.
    – Thufir
    18 mins ago
















2














There is the xargs program which transforms a file to command-line arguments. Simply prepend xargs to the command (with all arguments) for which you’d like to supply additional arguments from the file (let’s call it list.txt) and let xargs to read your file using standard input redirection.



< list.txt xargs sudo apt-get install -y


You can test it by putting echo before (or instead of) sudo or removing the -y option.






share|improve this answer























  • but can you make it simpler for this monkey?
    – Thufir
    22 mins ago








  • 1




    I am sorry, I don’t think there is any way to make this command simpler. Every character in this command has its own purpose. The only thing I can simplify is to write apt instead of apt-get.
    – Melebius
    19 mins ago












  • I know -- I was kidding. But, thanks.
    – Thufir
    18 mins ago














2












2








2






There is the xargs program which transforms a file to command-line arguments. Simply prepend xargs to the command (with all arguments) for which you’d like to supply additional arguments from the file (let’s call it list.txt) and let xargs to read your file using standard input redirection.



< list.txt xargs sudo apt-get install -y


You can test it by putting echo before (or instead of) sudo or removing the -y option.






share|improve this answer














There is the xargs program which transforms a file to command-line arguments. Simply prepend xargs to the command (with all arguments) for which you’d like to supply additional arguments from the file (let’s call it list.txt) and let xargs to read your file using standard input redirection.



< list.txt xargs sudo apt-get install -y


You can test it by putting echo before (or instead of) sudo or removing the -y option.







share|improve this answer














share|improve this answer



share|improve this answer








edited 24 mins ago

























answered 29 mins ago









Melebius

4,41751838




4,41751838












  • but can you make it simpler for this monkey?
    – Thufir
    22 mins ago








  • 1




    I am sorry, I don’t think there is any way to make this command simpler. Every character in this command has its own purpose. The only thing I can simplify is to write apt instead of apt-get.
    – Melebius
    19 mins ago












  • I know -- I was kidding. But, thanks.
    – Thufir
    18 mins ago


















  • but can you make it simpler for this monkey?
    – Thufir
    22 mins ago








  • 1




    I am sorry, I don’t think there is any way to make this command simpler. Every character in this command has its own purpose. The only thing I can simplify is to write apt instead of apt-get.
    – Melebius
    19 mins ago












  • I know -- I was kidding. But, thanks.
    – Thufir
    18 mins ago
















but can you make it simpler for this monkey?
– Thufir
22 mins ago






but can you make it simpler for this monkey?
– Thufir
22 mins ago






1




1




I am sorry, I don’t think there is any way to make this command simpler. Every character in this command has its own purpose. The only thing I can simplify is to write apt instead of apt-get.
– Melebius
19 mins ago






I am sorry, I don’t think there is any way to make this command simpler. Every character in this command has its own purpose. The only thing I can simplify is to write apt instead of apt-get.
– Melebius
19 mins ago














I know -- I was kidding. But, thanks.
– Thufir
18 mins ago




I know -- I was kidding. But, thanks.
– Thufir
18 mins ago













2














Something like this?



# check that the filename was supplied (keeping it simple for the example)
set -o nounset

packagefile=$1

# initialize the package variable
packages=''

# read the lines of the package file
while IFS= read -r line; do
packs+=" $line"
done < $packagefile

# apt install all of the packages
apt install -y $packs





share|improve this answer





















  • yes, perfect thanks. As an aside, is it possible or advisable to pipe apt search output through a script or utility? Assuming you know ahead of time that the result set is limited. You already answered the question I asked, it's just an aside.
    – Thufir
    47 mins ago








  • 1




    You can pipe the output but IMO that's really asking for it since you could get many matches that you didn't intend. I'd recommend outputing to a file first (like: apt search some-pack_name > packages) and then editing that file before doing the install.
    – Eric Mintz
    28 mins ago










  • It's the editing which is annoying.
    – Thufir
    23 mins ago
















2














Something like this?



# check that the filename was supplied (keeping it simple for the example)
set -o nounset

packagefile=$1

# initialize the package variable
packages=''

# read the lines of the package file
while IFS= read -r line; do
packs+=" $line"
done < $packagefile

# apt install all of the packages
apt install -y $packs





share|improve this answer





















  • yes, perfect thanks. As an aside, is it possible or advisable to pipe apt search output through a script or utility? Assuming you know ahead of time that the result set is limited. You already answered the question I asked, it's just an aside.
    – Thufir
    47 mins ago








  • 1




    You can pipe the output but IMO that's really asking for it since you could get many matches that you didn't intend. I'd recommend outputing to a file first (like: apt search some-pack_name > packages) and then editing that file before doing the install.
    – Eric Mintz
    28 mins ago










  • It's the editing which is annoying.
    – Thufir
    23 mins ago














2












2








2






Something like this?



# check that the filename was supplied (keeping it simple for the example)
set -o nounset

packagefile=$1

# initialize the package variable
packages=''

# read the lines of the package file
while IFS= read -r line; do
packs+=" $line"
done < $packagefile

# apt install all of the packages
apt install -y $packs





share|improve this answer












Something like this?



# check that the filename was supplied (keeping it simple for the example)
set -o nounset

packagefile=$1

# initialize the package variable
packages=''

# read the lines of the package file
while IFS= read -r line; do
packs+=" $line"
done < $packagefile

# apt install all of the packages
apt install -y $packs






share|improve this answer












share|improve this answer



share|improve this answer










answered 48 mins ago









Eric Mintz

484112




484112












  • yes, perfect thanks. As an aside, is it possible or advisable to pipe apt search output through a script or utility? Assuming you know ahead of time that the result set is limited. You already answered the question I asked, it's just an aside.
    – Thufir
    47 mins ago








  • 1




    You can pipe the output but IMO that's really asking for it since you could get many matches that you didn't intend. I'd recommend outputing to a file first (like: apt search some-pack_name > packages) and then editing that file before doing the install.
    – Eric Mintz
    28 mins ago










  • It's the editing which is annoying.
    – Thufir
    23 mins ago


















  • yes, perfect thanks. As an aside, is it possible or advisable to pipe apt search output through a script or utility? Assuming you know ahead of time that the result set is limited. You already answered the question I asked, it's just an aside.
    – Thufir
    47 mins ago








  • 1




    You can pipe the output but IMO that's really asking for it since you could get many matches that you didn't intend. I'd recommend outputing to a file first (like: apt search some-pack_name > packages) and then editing that file before doing the install.
    – Eric Mintz
    28 mins ago










  • It's the editing which is annoying.
    – Thufir
    23 mins ago
















yes, perfect thanks. As an aside, is it possible or advisable to pipe apt search output through a script or utility? Assuming you know ahead of time that the result set is limited. You already answered the question I asked, it's just an aside.
– Thufir
47 mins ago






yes, perfect thanks. As an aside, is it possible or advisable to pipe apt search output through a script or utility? Assuming you know ahead of time that the result set is limited. You already answered the question I asked, it's just an aside.
– Thufir
47 mins ago






1




1




You can pipe the output but IMO that's really asking for it since you could get many matches that you didn't intend. I'd recommend outputing to a file first (like: apt search some-pack_name > packages) and then editing that file before doing the install.
– Eric Mintz
28 mins ago




You can pipe the output but IMO that's really asking for it since you could get many matches that you didn't intend. I'd recommend outputing to a file first (like: apt search some-pack_name > packages) and then editing that file before doing the install.
– Eric Mintz
28 mins ago












It's the editing which is annoying.
– Thufir
23 mins ago




It's the editing which is annoying.
– Thufir
23 mins ago


















draft saved

draft discarded




















































Thanks for contributing an answer to Ask Ubuntu!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1106268%2fapt-install-list-of-packages-from-file%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

404 Error Contact Form 7 ajax form submitting

How to know if a Active Directory user can login interactively

Refactoring coordinates for Minecraft Pi buildings written in Python