Answers:
如果您的文件(例如pkglist
)包含要安装的软件包列表,例如:
pkg1
pkg2
pkg3
要么
pkg1 pkg2 pkg3
然后,您可以apt
使用以下命令安装该软件包:
sudo apt-get install $(cat pkglist)
xargs sudo apt-get install < pkglist
有关更多信息,apt-get install
请访问man apt-get
安装部分。
xargs sudo apt-get -y install < pkglist
xargs -a pkglist sudo apt install
。
将所有程序包名称放入文件中(每行一个程序包名称)。然后运行以下命令以自动安装给定的软件包。
while read -r line; do sudo apt-get -y install "$line"; done < /path/to/the/packages/file
例:
$ cat file
vlc
firefox
$ while read -r line; do sudo apt-get install "$line"; done < file
[sudo] password for avinash:
Reading package lists... Done
Building dependency tree
Reading state information... Done
vlc is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 499 not upgraded.
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
ttf-lyx
The following packages will be upgraded:
firefox
1 upgraded, 0 newly installed, 0 to remove and 498 not upgraded.
Need to get 35.8 MB of archives.
After this operation, 24.3 MB of additional disk space will be used.
Get:1 http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ trusty-updates/main firefox amd64 33.0+build2-0ubuntu0.14.04.1 [35.8 MB]
0% [1 firefox 67.0 kB/35.8 MB 0%] 10.4 kB/s 57min 16s^