How to use apt-get to install packages without one specify package?
You can do
list=$(apt-cache --names-only search ^k3b-* | awk '{ print $1 }' | \
grep -v bad-pkg)
sudo apt-get install $list
Say you don't want to install the k3b-extrathemes package. There might be no practical way to do this but to list all the packages except for the one: sudo apt-get install k3b-data k3b-dbg
.
However you can do that with some aid:
sudo apt-get install $(apt-cache --no-generate pkgnames k3b \
| grep -v extrathemes | tr '\n' ' ')
That's not terribly partical. apt-cache ...
returns the name of the packages, grep -v PACKAGENAME
excludes the packages and the tr
command replaces new lines by spaces.
I discovered a much simpler way of doing this:
sudo aptitude install <package>
This will use aptitude
instead of apt-get
- which provides you with more options. When you see something like the following:
The following NEW packages will be installed:
...
0 packages upgraded, 12 newly installed, 0 to remove and 0 not upgraded.
Need to get 130 MB/130 MB of archives. After unpacking 216 MB will be used.
Do you want to continue? [Y/n/?]
Instead of pressing 'y', type the following:
-<package_to_skip>
That's a '-' followed by the name of the package to skip. Then you can proceed with the installation as per normal.