#!/bin/bash
NUMBER="-1"

while true
do
    clear

    LOGS=( $(sudo find /var/tmp/portage/ -mindepth 1 -maxdepth 5 -name "build.log")  $(sudo find /var/tmpnotmpfs/portage/ -mindepth 1 -maxdepth 5 -name "build.log") )
    LEN=${#LOGS[@]}

    for (( i=0; i<$LEN; i++ ));
    do
        echo "$(( $i + 1 )) - ${LOGS[$i]}"
    done

    echo
    read -rsp $'Select number to show logs...\n' -t2 -n1 NUMBER

    [[ $NUMBER -gt 0 ]] && break
done

echo -e "\n\e[93m File: ${LOGS[$NUMBER-1]} \e[0m\n"
sudo cat ${LOGS[$NUMBER-1]}
