From 427e606aa2921d92d221173758b9c5978d3d1795 Mon Sep 17 00:00:00 2001 From: layman Date: Tue, 8 Mar 2022 22:23:33 +0100 Subject: [PATCH] add script to prune old entries in efi --- pruneEfiStubs.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100755 pruneEfiStubs.sh diff --git a/pruneEfiStubs.sh b/pruneEfiStubs.sh new file mode 100755 index 0000000..e847f5e --- /dev/null +++ b/pruneEfiStubs.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +mapfile ENTRIES < <(efibootmgr -v | tail +4 | grep HD\() +for entry in "${ENTRIES[@]}" ; do +# echo "Processing" +# echo "$entry" + BOOTID=$( sed -e "s/Boot\(.\{4\}\).*/\1/" <<<$entry ) + FILE=$( sed -e "s/.*File(\(.*\)).*/\1/" <<<$entry) + if [[ -f "$FILE" ]] ; then + echo "$FILE exists" + else + echo "$FILE doesn't exists" + efibootmgr -B -b "$BOOTID" + fi +done