dotfiles/.bin/OLD/whatmem
2024-02-14 07:55:58 +01:00

15 lines
375 B
Bash
Executable File

#!/bin/sh
for i in $@
do
RES="$(ps -x -o "comm rss" | grep -Ei "^$i ")"
if [ ! -z "$RES" ]
then
echo "$RES" | xargs -n2 -I{} echo "Adding: {} KB"
TOTAL=$(( TOTAL + $(echo "$RES" | awk '{ sum=sum+$2; } END { printf("%d", sum); }') ))
else
echo "$@ not found."
fi
done
echo $TOTAL | awk '{ printf("Summary: %.2f MB\n", $1/1024); }'