Alright heres what I got. This
Code:
seq 1 10 | sed "s/^/ -e ':/" | sed "s/$/ '/" | tr "\\n" " "
Will give me the range all on one line.
I tried the code you just posted
Code:
echo {a..z} {1..10}
echo -e\ {1..10}
echo -e\ :{8000..9000}[^0-9]*
netstat --tcp --numeric | awk 'NR>2 {print $5}' | grep $( echo -e\ :{8000..9000}[^0-9]* )
and it gave me
Code:
-e :8000[^0-9]* -e :8001[^0-9]* -e :8002[^0-9]* -e :8003[^0-9]* -e :8004[^0-9]* -e :8005[^0-9]* -e :8006[^0-9]* -e :8007[^0-9]* -e :8008[^0-9]* etc etc..
So now I come to the other part. The if then. My script goes like this
Code:
if [ "$(netstat --tcp --numeric | cut -c 45-65 | sort -u | sed '/Foreign/d' | sed '/^$/d' | grep -e ':80' -e ':443')" ]; then
echo 'http / https' && netstat --tcp --numeric | cut -c 45-65 | sort -u | sed '/Foreign/d' | sed '/^$/d' | grep -e ':80' -e ':443'
fi
So, the if has to contain the whole statement so that the http / https will only echo if there is output from the original statement. Is there a better way?
Bookmarks