From 697144f451fdbce6c70895d3c232c1a200a5238a Mon Sep 17 00:00:00 2001 From: earnest ma Date: Thu, 23 May 2024 12:09:29 -0400 Subject: [PATCH] * --- fedora_rm_old_kernels.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 fedora_rm_old_kernels.sh diff --git a/fedora_rm_old_kernels.sh b/fedora_rm_old_kernels.sh new file mode 100644 index 0000000..3e50c5b --- /dev/null +++ b/fedora_rm_old_kernels.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +old_kernels=($(dnf repoquery --installonly --latest-limit=-1 -q)) +if [ "${#old_kernels[@]}" -eq 0 ]; then + echo "No old kernels found" + exit 0 +fi + +if ! dnf remove "${old_kernels[@]}"; then + echo "Failed to remove old kernels" + exit 1 +fi + +echo "Removed old kernels" +exit 0