Set ipv4 ports of user xxx from p1 to p2 in var
Code:
var=`lsof -n -i4:$p1-$p2 -a -u$xxx | awk '/IPv4/ {print $8}' | cut -d':' -f2 | cut -d'-' -f1 | sort | uniq | tr '\n' ' ' `
Does the trick but very ugly, it should be possible in one regular expression