Before you begin
- Bash 4+ on Linux.
- Required tools: Bash builtins and optional tools explained below. Requires APT or DNF and existing package metadata.
Set up your example
- Save as linux-cached-package-updates.sh.
- Open a terminal in its folder.
- Run bash "linux-cached-package-updates.sh" --help; invoking bash does not require executable permission.
This recipe uses your own local input or creates its own example output. Follow the setup steps below.
Download the ZIP, extract it, and open a terminal inside the extracted folder. The source file is linux-cached-package-updates.sh.
Run the script
bash "linux-cached-package-updates.sh"If your system uses python3 instead of python, use that command for Python examples. Keep paths containing spaces in quotes. Required inputs and optional settings are described in the code and setup steps.
What to expect
Cached upgrade candidates are listed; stale caches can miss available updates.
The complete script
#!/usr/bin/env bash
set -euo pipefail
if [[ ${1:-} == --help || ${1:-} == -h ]]; then
cat <<\SCRIPTAGE_HELP
Inspect cached package updates
Usage: bash linux-cached-package-updates.sh
Report updates from existing APT or DNF metadata without refreshing or installing.
Read-only local report.
SCRIPTAGE_HELP
exit 0
fi
if command -v apt >/dev/null 2>&1; then
apt list --upgradable 2>/dev/null
elif command -v dnf >/dev/null 2>&1; then
set +e
dnf --cacheonly check-update
status=$?
set -e
if (( status != 0 && status != 100 )); then exit "$status"; fi
else
printf 'Requires APT or DNF and an existing metadata cache.\n' >&2
exit 1
fi
Open source as plain text · Download source and sample files
How it works
- Report updates from existing APT or DNF metadata without refreshing or installing.
- Required commands are checked before collecting the report.
- The output is a local snapshot; restricted permissions or unavailable kernel data can limit visibility.
Make it your own
Adjust scope
Change the branch order if both managers exist. Refresh metadata separately through your approved process.
Save a snapshot
Redirect to a new unused .txt filename for comparison. Shell redirection can overwrite files; choose a fresh name.
Change one setting at a time, run it again on sample data, and compare the output. The customization guide walks through this process.
If something goes wrong
A required tool is missing.
Install its package through your normal distribution maintenance process. This script does not install anything.
The report is empty or permission is denied.
Requires APT or DNF and existing package metadata.
Reference & next steps
These official references explain the underlying tools. The Scriptage example and guide are original instructional content. See verification notes for what has been checked and the limits of those checks.
Copies a template for your own notes. It does not send anything.