Используйте файл манифеста распространения в качестве базового пакета. Сортировка результатов, установленных вручную, в группы пакетов по архитектуре и разделу, поэтому проще сосредоточиться на группах пакетов (возможно, вам не нужны некоторые разделы).
https://gist.github.com / darrenleeweber / 8cc570ff402f19af7fa4
#!/bin/bash
manifest_url='http://releases.ubuntu.com/releases/trusty/ubuntu-14.04.3-desktop-amd64.manifest'
manifest_file=$(echo $manifest_url | sed -e 's#.*/##g')
if [ ! -e $manifest_file ]; then
wget -q $manifest_url
fi
cat $manifest_file | cut -f1 | sort -u > default_installed.txt
aptitude search '~i !~M' -F '%p' --disable-columns | sort -u > currently_installed.txt
comm -23 currently_installed.txt default_installed.txt > manually_installed.txt
# sort the 'mannually_installed.txt' packages by architecture and section
mkdir -p package_files
while read p; do
apt-cache show $p > info.txt
arch=$(grep -m1 'Architecture: ' info.txt | sed -e 's/Architecture: //')
section=$(grep -m1 'Section: ' info.txt | sed -e 's/Section: //' -e 's/\//_/g')
file="${arch}_${section}_packages.txt"
echo $p >> "package_files/$file"
done <manually_installed.txt
rm info.txt
Вы должны убедиться, что $ jobid имеет значение, которое может использоваться как имя каталога.