Skip to content

Instantly share code, notes, and snippets.

@dwallraff
Created September 13, 2016 18:41
Show Gist options
  • Select an option

  • Save dwallraff/cf50b2ac861585f4feee7f5f27369838 to your computer and use it in GitHub Desktop.

Select an option

Save dwallraff/cf50b2ac861585f4feee7f5f27369838 to your computer and use it in GitHub Desktop.
Extract hashes
# Extract md5 hashes
egrep -oE '(^|[^a-fA-F0-9])[a-fA-F0-9]{32}(1|$)' *.txt | egrep -o '[a-fA-F0-9]{32}' > md5-hashes.txt
# An alternative could be with sed
sed -rn 's/.*[^a-fA-F0-9]([a-fA-F0-9]{32})[^a-fA-F0-9].*/1/p' *.txt > md5-hashes
# Note: The above regexes can be used for SHA1, SHA256 and other unsalted hashes represented in hex.
# The only thing you have to do is change the '{32}' to the corresponding length for your desired hash-type.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment