linux - Cut partial element from specific column in print output -
for while i've been using simple command extract data netstat show how many connections server coming specific ip.
i'm trying migrate command, while adding bit more detail, using ss i'm getting bit stuck on how remove element specific column.
what have far following:
ss -t 2>/dev/null | awk -v ofs='\t\t' '{print $4, $5}' | sort | uniq -c | sort -nr
and output similar to:
1 local address:port 1 172.31.6.21:imaps 124.170.xxx.xxx:47498 1 172.31.6.21:imaps 124.170.xxx.xxx:47122
the problem have here cannot work out how consolidated values each source ip ignores ":port" factor. i've tried few things using cut command, affects first column, output not precise desired.
the type of output want able see be:
1 local address:port 22 172.31.6.21:imaps 124.170.xxx.xxx 31 172.31.6.17:http 134.162.xxx.xxx
the local ip, protocol type, , source ip important results. want remove port element, when use sort function, can see number of connections specific local ip specific protocol specific source ip.
will do?
ss -t 2>/dev/null | awk -v ofs='\t\t' '{print $4, $5}' | cut -f1,2 -d ":" | uniq | sort | uniq -c | sort -nr
update: sorry, didn't notice comment first column.
update 2: adding "uniq", should trick.
Comments
Post a Comment