Skip to content

Instantly share code, notes, and snippets.

@mjf
Last active December 17, 2015 01:58
Show Gist options
  • Save mjf/5531936 to your computer and use it in GitHub Desktop.
Save mjf/5531936 to your computer and use it in GitHub Desktop.
Match lines containing IPv4 private addresses. TODO: aggregate into single regular expression
#! /bin/sed -f
# 10.0.0.0/8
# 127.0.0.0/8
/1\(0\|27\)\(\.\([0-9]\|[1-9][0-9]\|10[0-9]\|1[1-9][0-9]\|25[0-5]\|2[0-4][0-9]\)\)\{3\}/ p
# 172.16.0.0/19
# 192.168.0.0/16
/\(172\.\(1[6-9]\|2[0-9]\|3[0-1]\)\|192\.168\)\(\.\([0-9]\|[1-9][0-9]\|10[0-9]\|1[1-9][0-9]\|25[0-5]\|2[0-4][0-9]\)\)\{2\}/ p
d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment