From ca23a30bd3958a9004760196881532f8d8435d86 Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Sat, 24 Jan 2026 21:24:13 -0500 Subject: [PATCH] Fix memory slot count bug in get_memory_details The previous grep-based counting was including Size: lines from Physical Memory Array sections, causing incorrect counts (e.g., 5/4 instead of 4/4). Now uses awk to only count Size: lines within Memory Device sections. Co-Authored-By: Claude Opus 4.5 --- proxDoc.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/proxDoc.sh b/proxDoc.sh index b8c638c..0171115 100755 --- a/proxDoc.sh +++ b/proxDoc.sh @@ -209,8 +209,12 @@ get_memory_details() { } ' echo -e "\n${GREEN}Memory Summary:${NC}" - echo -e " Total Slots: $(dmidecode -t memory | grep -c "Memory Device")" - echo -e " Populated: $(dmidecode -t memory | grep "Size:" | grep -cv "No Module")" + # Count total memory device slots (excluding Physical Memory Array entries) + local total_slots=$(dmidecode -t memory | awk '/^Memory Device$/,/^$/ {if (/Size:/) count++} END {print count}') + # Count populated slots (Size: lines with actual values, not "No Module Installed") + local populated=$(dmidecode -t memory | awk '/^Memory Device$/,/^$/ {if (/Size:/ && !/No Module/) count++} END {print count}') + echo -e " Total Slots: $total_slots" + echo -e " Populated: $populated" echo -e " Max Capacity: $(dmidecode -t memory | grep "Maximum Capacity" | head -1 | awk '{print $3" "$4}')" }