Thanks Anduril for a push in the right direction for the numerical comparison. Got it working. It's fully functional and running.
Final code:
Code:#!/bin/bash netstat -ant | awk -F" " '{print $5}' | awk -F":" '{print $2}' | sed '/^$/d' | grep -E "0|1|2|3|4|5|6|7|8|9" > netstat.txt; awk '!x[$0]++' netstat.txt > netstat2.txt && cat netstat2.txt | sed '/^$/d' netstat2.txt; LINES=$(awk 'END {print NR}' netstat2.txt) NLINES=`echo $LINES`; THREE=3; if [ $NLINES -lt $THREE ]; then echo "Your safe" else echo "[danger]"; /path/to/ui_executable; fi