Install all packages from the previous version export OLDV=38 NEWV=39 sudo -E port -pNc install "python${NEWV}" $(port -qv installed | egrep -e "^\s*py${OLDV}" | perl -ane 'chomp; $_ = $F[0]; s/py'${OLDV}'/py'${NEWV}'/; print $_, " ";') port select changes