3000번대 포트 중 사용하지 않는 포트를 표시합니다.

function idleports()  
{  
    cols=10  
    count=0  
    output=""  
  
    listening_ports=($(sudo ss -tlpn | grep -o ':30[0-9]*' | sed 's/://g' | sort | uniq))  
  
    for port in {3000..3099}; do  
        if [[ " ${listening_ports[@]} " =~ " $port " ]]; then  
            output+="\033[38;5;235m$port\033[0m  "  
        else  
            output+="$port  "  
        fi  
  
        ((count++))  
        if ((count % cols == 0)); then  
            output+='\n'  
        fi  
    done  
  
    if ((count % cols != 0)); then  
        output+='\n'  
    fi  
  
    echo -e "$output"  
}  

아닛 이건 꿀팁이군요... 감사합니다.