#!/bin/bash cd /var/cache/apt/archives || { echo Failed to change to /var/cache/apt/archives >&2 exit 1 } apt-get -f -y update apt-get --print-uris -d -y dist-upgrade | grep "^'" | while read uri x; do # filter out all but the URIs with the grep # grab just the first arg uri=${uri#\'}; uri=${uri%\'}; # trim the leading and trailing quotes from the URI wget --limit-rate=5k "$uri" done