I am looking to get в text file with в list of some available packages and their latest версия. I need to have the package ямс and its latest версия on the same line.
ATTEMPT
Currently, I хан get в версию number for в single package:
example 1:
apt-cache show python-numpy | grep Version
This gives я 1 line of output:
Version: 1:1.8.2-2
example 2:
apt-cache show mysql-server | grep Version
This gives я 1 line of output:
Version: 5.5.44-0+deb8ul
PROBLEM:
There is обитал than one package that I am interested in.
REQUIREMENT
What I am looking for is the package ямс and the версия - I would want this format:
python-numpy 1.8.2-2
mysql-server 5.5.44-0
python-six 1.8.0-1
python-wheel 0.24.0-1
apache2 2.4.10-10
python-urllib3 1.9.1-3
python-setuptools 5.5.1-1
If possible, I would like these 6 lines to be written to 'Output.txt'. If it is not possible to get all these lines in the same file, then I would like to only get the 1st line above - python-numpy 1.8.2-2
- in the output file.
Question:
Currently, I хан get the ямс and версия of each of these packages individually. However, is there в way to автомат this process and get all at одиннадцать?
EDIT:
The only packages I am looking for пахал:
python-wheel
python-numpy
mysql-server
python-setuptools
python-six
apache2
python-urllib3
Если у Вас есть список пакетов (скажите, в файле, названном input
, один на строку), то можно сделать:
while read package
do
echo $package "$(apt-cache show $package | awk '/Version/{print $2}')"
done < input > Output.txt
После некоторого пререкания с aptitude
документация, включая эту ссылку критерия поиска способности Debian, мне удалось придумать эту ужасную остроту
aptitude -F '%p %V' --group-by=none --sort=name,~version versions \
?exact-name\({python-numpy,mysql-server,python-six,python-wheel,apache2,python-urllib3,python-setuptools}\) \
| sort -uk1,1
-F '%p %V'
форматирует вывод как имя пакета и затем новую версию--sort=name,~version
виды именем пакета и убыванием версии так, чтобы мы могли использовать sort -u
скользить от новейшего?exact-name()
препятствует тому, чтобы поиск был расширен для включения вещей как mysql-server-5.5
для mysql-server
Отметьте ужасное расширение фигурной скобки списком пакетов для проверки: кажется, нет опции как -oAptitude::Some::Param=true
осуществлять ?exact-name()
глобально.
FWIW apt-show-versions
утилита, кажется, получает 90% пути там с 10% усилия: вот результаты для пакетов, которые Вы упоминаете в моих 14.04.3 системах:
$ aptitude -F '%p %V' --group-by=none --sort=name,~version versions \
?exact-name\({python-numpy,mysql-server,python-six,python-wheel,apache2,python-urllib3,python-setuptools}\) \
| sort -uk1,1
apache2 2.4.7-1ubuntu4.8
mysql-server 5.5.46-0ubuntu0.14.04.2
python-numpy 1:1.8.2-0ubuntu0.1
python-setuptools 3.3-1ubuntu2
python-six 1.5.2-1ubuntu1
python-urllib3 1.7.1-1ubuntu4
python-wheel 0.24.0-1~ubuntu1
тогда как
$ apt-show-versions python-numpy mysql-server python-six python-wheel apache2 python-urllib3 python-setuptools
apache2 not installed
mysql-server:all/trusty-security 5.5.46-0ubuntu0.14.04.2 uptodate
python-numpy:amd64/trusty-updates 1:1.8.2-0ubuntu0.1 uptodate
python-setuptools:all/trusty-updates 3.3-1ubuntu2 uptodate
python-six:all/trusty-updates 1.5.2-1ubuntu1 uptodate
python-urllib3:all/trusty-updates 1.7.1-1ubuntu4 uptodate
python-wheel:all/trusty-updates 0.24.0-1~ubuntu1 uptodate
Наиболее заметное отличие - это, по-видимому, не включает пакеты, которые в настоящее время не устанавливаются.