#!/bin/bash if ! [ "$1" = "--i386" ] && ! [ "$1" = "--amd64" ] then echo Missing or invalid argument: "$1" exit 1 fi cd /tmp if [ ! -f manifest-i386 ] then wget -qO manifest-i386 "http://releases.ubuntu.com/trusty/ubuntu-14.04.1-desktop-i386.manifest" fi if [ ! -f manifest-amd64 ] then wget -qO manifest-amd64 "http://releases.ubuntu.com/trusty/ubuntu-14.04.1-desktop-amd64.manifest" fi pkgs=("${@:2}") extra=() for pkg in ${pkgs[@]} do if [ "$1" = "--i386" ] && ! grep -q "$pkg" manifest-i386 then extra+=("$pkg") elif [ "$1" = "--amd64" ] && ! grep -q "$pkg" manifest-amd64 then extra+=("$pkg") fi done printf -- '%s\n' "${extra[@]}"