Skip to content

Instantly share code, notes, and snippets.

@dotwaffle
Last active February 8, 2016 20:42
Show Gist options
  • Save dotwaffle/ff6e790ae98104d82d40 to your computer and use it in GitHub Desktop.
Save dotwaffle/ff6e790ae98104d82d40 to your computer and use it in GitHub Desktop.
Put an "ss" expression in the parameters to filter, i.e. dst 1.0.0.0/8
#!/bin/bash
ss -tine $@ \
| tr '\t' ' ' \
| sed -e '1d' \
-e ': # first line is for humans' \
-e 's/sk:ffff[0-9a-fA-F]\+//g' \
-e ': # remove the skbuf stuff' \
-e 's/\s\+ino:[0-9]\{,8\}//g' \
-e ': # remove the ino stuff' \
-e 'N;s/\n/ /g' \
-e ': # join the next two lines together' \
-re 's/(timer:[^ ]+)(.*)/\2 \1/g' \
-e ': # move the timer to the end (neater)' \
-e 's/\s+cubic/ cubic/g' \
-e ': # remove all space after the IP/ports' \
-e 's/send /send:/g' \
-e ': # send does not have a colon, annoying!'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment