Skip to content

Instantly share code, notes, and snippets.

@joli80
Last active November 2, 2016 20:33
Show Gist options
  • Save joli80/5e9d41e299f52872c243de868bd7d5fb to your computer and use it in GitHub Desktop.
Save joli80/5e9d41e299f52872c243de868bd7d5fb to your computer and use it in GitHub Desktop.
Extract IP all addresses from a text file
# Credit to http://www.gfi.com/blog/windows-powershell-extracting-strings-using-regular-expressions/
$input_path = 'c:\ps\ip_addresses.txt'
$regex = '\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b'
select-string -Path $input_path -Pattern $regex -AllMatches | % { $_.Matches } | % { $_.Value }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment