Skip to content

Commit

Permalink
only print swap if /proc/swaps has 2 or more lines; make variable swa…
Browse files Browse the repository at this point in the history
…p_count print all swap size
  • Loading branch information
wick3dr0se committed Nov 23, 2021
1 parent 397e7cd commit df4d0c2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions fetch.sh
Expand Up @@ -127,8 +127,9 @@ awk '/MemTotal:/ {printf "%d MiB\n", $2 / 1024}' /proc/meminfo | tr -d '\n'


# // SWAP // print 'Size' from /proc/swaps
swap_kb=$(cat /proc/swaps | grep -vi filename | awk '{n+=$3} END {print n}')
if [ -n "$swap_kb" ] ; then
swap_kb=$(head /proc/swaps | grep '/dev' | awk '{print($3)}')
swap_count=$(head /proc/swaps | wc -l)
if [[ $swap_count -ge 2 ]] ; then
let "swap_mb = $swap_kb / 1024"
echo -ne " \e \e \e \e "
echo -ne "${YELLOW}swap${NC} ~ "
Expand Down

0 comments on commit df4d0c2

Please sign in to comment.