apt install [duplicate]
This question already has an answer here:
Install list of packages using apt-get
3 answers
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
marked as duplicate by dessert, Community♦ Jan 2 at 18:21
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Install list of packages using apt-get
3 answers
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
marked as duplicate by dessert, Community♦ Jan 2 at 18:21
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new 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
Jan 2 at 13:33
LOL, yes, exactly. How? (I'll google that, also, of course.)
– Thufir
Jan 2 at 13:35
add a comment |
This question already has an answer here:
Install list of packages using apt-get
3 answers
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
This question already has an answer here:
Install list of packages using apt-get
3 answers
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.
This question already has an answer here:
Install list of packages using apt-get
3 answers
apt bash package-management software-installation automation
apt bash package-management software-installation automation
edited Jan 2 at 13:46
Thufir
asked Jan 2 at 13:24
ThufirThufir
1,53084394
1,53084394
marked as duplicate by dessert, Community♦ Jan 2 at 18:21
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by dessert, Community♦ Jan 2 at 18:21
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new 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
Jan 2 at 13:33
LOL, yes, exactly. How? (I'll google that, also, of course.)
– Thufir
Jan 2 at 13:35
add a comment |
I don't really understand your question, you could read from the file and run the apt command on each read line!
– George Udosen
Jan 2 at 13:33
LOL, yes, exactly. How? (I'll google that, also, of course.)
– Thufir
Jan 2 at 13:35
I don't really understand your question, you could read from the file and run the apt command on each read line!
– George Udosen
Jan 2 at 13:33
I don't really understand your question, you could read from the file and run the apt command on each read line!
– George Udosen
Jan 2 at 13:33
LOL, yes, exactly. How? (I'll google that, also, of course.)
– Thufir
Jan 2 at 13:35
LOL, yes, exactly. How? (I'll google that, also, of course.)
– Thufir
Jan 2 at 13:35
add a comment |
2 Answers
2
active
oldest
votes
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.
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 writeapt
instead ofapt-get
.
– Melebius
Jan 2 at 14:06
add a comment |
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
yes, perfect thanks. As an aside, is it possible or advisable to pipeapt 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
Jan 2 at 13:38
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
Jan 2 at 13:57
It's the editing which is annoying.
– Thufir
Jan 2 at 14:02
With bash, it would probably make more sense to slurp all the lines into an array and use thatmapfile -t packs < "$packagefile" ; apt-get install -y "${packs[@]}"
– steeldriver
Jan 2 at 15:28
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
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 writeapt
instead ofapt-get
.
– Melebius
Jan 2 at 14:06
add a comment |
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.
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 writeapt
instead ofapt-get
.
– Melebius
Jan 2 at 14:06
add a comment |
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.
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.
edited Jan 2 at 14:00
answered Jan 2 at 13:55
MelebiusMelebius
4,57751839
4,57751839
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 writeapt
instead ofapt-get
.
– Melebius
Jan 2 at 14:06
add a comment |
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 writeapt
instead ofapt-get
.
– Melebius
Jan 2 at 14:06
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
Jan 2 at 14:06
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
Jan 2 at 14:06
add a comment |
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
yes, perfect thanks. As an aside, is it possible or advisable to pipeapt 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
Jan 2 at 13:38
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
Jan 2 at 13:57
It's the editing which is annoying.
– Thufir
Jan 2 at 14:02
With bash, it would probably make more sense to slurp all the lines into an array and use thatmapfile -t packs < "$packagefile" ; apt-get install -y "${packs[@]}"
– steeldriver
Jan 2 at 15:28
add a comment |
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
yes, perfect thanks. As an aside, is it possible or advisable to pipeapt 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
Jan 2 at 13:38
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
Jan 2 at 13:57
It's the editing which is annoying.
– Thufir
Jan 2 at 14:02
With bash, it would probably make more sense to slurp all the lines into an array and use thatmapfile -t packs < "$packagefile" ; apt-get install -y "${packs[@]}"
– steeldriver
Jan 2 at 15:28
add a comment |
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
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
answered Jan 2 at 13:37
Eric MintzEric Mintz
559112
559112
yes, perfect thanks. As an aside, is it possible or advisable to pipeapt 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
Jan 2 at 13:38
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
Jan 2 at 13:57
It's the editing which is annoying.
– Thufir
Jan 2 at 14:02
With bash, it would probably make more sense to slurp all the lines into an array and use thatmapfile -t packs < "$packagefile" ; apt-get install -y "${packs[@]}"
– steeldriver
Jan 2 at 15:28
add a comment |
yes, perfect thanks. As an aside, is it possible or advisable to pipeapt 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
Jan 2 at 13:38
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
Jan 2 at 13:57
It's the editing which is annoying.
– Thufir
Jan 2 at 14:02
With bash, it would probably make more sense to slurp all the lines into an array and use thatmapfile -t packs < "$packagefile" ; apt-get install -y "${packs[@]}"
– steeldriver
Jan 2 at 15:28
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
Jan 2 at 13:38
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
Jan 2 at 13:38
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
Jan 2 at 13:57
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
Jan 2 at 13:57
It's the editing which is annoying.
– Thufir
Jan 2 at 14:02
It's the editing which is annoying.
– Thufir
Jan 2 at 14:02
With bash, it would probably make more sense to slurp all the lines into an array and use that
mapfile -t packs < "$packagefile" ; apt-get install -y "${packs[@]}"
– steeldriver
Jan 2 at 15:28
With bash, it would probably make more sense to slurp all the lines into an array and use that
mapfile -t packs < "$packagefile" ; apt-get install -y "${packs[@]}"
– steeldriver
Jan 2 at 15:28
add a comment |
I don't really understand your question, you could read from the file and run the apt command on each read line!
– George Udosen
Jan 2 at 13:33
LOL, yes, exactly. How? (I'll google that, also, of course.)
– Thufir
Jan 2 at 13:35