etc.git


etc

~ scripts and random things
git clone https://github.com/djnnvx/etc.git
log | files | refs | archive

get-tcp.sh (418B)

      1 #!/bin/bash
      2 
      3 tail -n +2 /proc/net/tcp | while read -r _ local remote _; do
      4     ip_local=$(echo ${local%:*} | sed 's/../0x& /g' | awk '{printf "%d.%d.%d.%d", $4, $3, $2, $1}')
      5     ip_remote=$(echo ${remote%:*} | sed 's/../0x& /g' | awk '{printf "%d.%d.%d.%d", $4, $3, $2, $1}')
      6     port_local=$((16#${local##*:}))
      7     port_remote=$((16#${remote##*:}))
      8 
      9     echo "$ip_local:$port_local -> $ip_remote:$port_remote"
     10 done
     11